You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im trying to do a POST to my server i configured my gateway as follows:
importMappersmithfrom'mappersmith';Mappersmith.Env.USE_PROMISES=true;varmanifest={host: 'http://localhost:3000',rules: [{values: {gateway: {headers: {'Content-Type': 'application/json'}}}}],resources: {CreateMixData: {search: 'post:/search',data: '/data'}}};exportdefaultMappersmith.forge(manifest);```and im calling it as:```jsAPI.CreateMixData.search({body:JSON.stringify({category:21})})
The problem is, when i look at the call on chrome the content-type is "Content-Type:application/json, application/json" instead of "Content-Type:application/json" , and for this reason my server dont know how to parse it.
The problem happens on any verb except for GET , and i tracked down the problem to the following method on vanilla-gateway:
_performRequest: function(method){varemulateHTTP=this.shouldEmulateHTTP(method);varrequestMethod=method;varrequest=newXMLHttpRequest();this._configureCallbacks(request);if(emulateHTTP){this.body=this.body||{};if(typeofthis.body==='object')this.body._method=method;requestMethod='POST';}request.open(requestMethod,this.url,true);if(emulateHTTP)request.setRequestHeader('X-HTTP-Method-Override',method);this._setContentTypeHeader(request);// HERE THE CONTENT-TYPE IS SETthis._setUserDefinedHeaders(request);// HERE THE CONTENT-TYPE IS SET AGAIN (DUPLICATION)varargs=[];if(this.body!==undefined){args.push(Utils.params(this.body));}request.send.apply(request,args);},
Thanks :)
The text was updated successfully, but these errors were encountered:
Ive tried with 'content-type' but still doenst work... actually i think the line of code you highlighted works... the problem is in _setContentTypeHeader you call request.setRequestHeader('Content-Type', contentType); which sets the correct content type... but on the next function call _setUserDefinedHeaders you are just setting all headers again (including content-type) and for this reason it duplicate this header. A simple filter on _setUserDefinedHeaders to avoid setting content-type again should do the trick.
Im trying to do a POST to my server i configured my gateway as follows:
The problem is, when i look at the call on chrome the content-type is "Content-Type:application/json, application/json" instead of "Content-Type:application/json" , and for this reason my server dont know how to parse it.
The problem happens on any verb except for GET , and i tracked down the problem to the following method on vanilla-gateway:
Thanks :)
The text was updated successfully, but these errors were encountered: