简体   繁体   中英

Amplifyjs GET request with body

I'd like to be able to use GET with message-body using AmplifyJS.

My question is specifically about how to achieve that with AmplifyJS.

Synthetic tests work fine (Fiddler being my test client). But when I do it through AmplifyJS, the "body" is added to the query string. (Edit: Is this a limitation of underlying jQuery "ajax" or that's AmplifyJS's choice)

amplify.request.define('trickyGet', 'ajax', {
                url: 'entity/{param}',
                dataType: 'json',
                type: 'GET',
                contentType: '???'
            });

then

amplify.request({
                    resourceId: 'trickyGet',
                    data: { param: 'paramVal', data: JSON.stringify({'complex1': 'complex1Val'}) },
                    //data: { param: 'paramVal', data: {'complex1': 'complex1Val'}) },
                    success: callbacks.success,
                    error: callbacks.error
                });

I tried all kinds of combinations with how my complex data is represented and what content-type to use.

If I change type to POST (and of course change my API end point), everything works ( data is in the message-body). But with get, data is appended to query string (by AplifyJS).

amplify.js使用jQuery的ajax()方法,该方法又限制了get请求期间data的发送方式。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM