Open muj-beg opened 7 years ago
+1
@muj-beg did you found a way to fix this?
Instead of passing an object to the body property, I just passed a string using a deparam module, like qs or query-string
@gilbarbara We ended up doing this:
const shouldUrlEncodeContent =
request.body && typeof request.body !== 'string' &&
request.headers && typeof request.headers['Content-Type'] === 'string' &&
request.headers['Content-Type'].indexOf('application/x-www-form-urlencoded') === 0;
if (shouldUrlEncodeContent)
request.body = QueryString.stringify(request.body);
Calling
Rx.DOM.ajax()
with content type set toapplication/x-www-form-urlencoded
and a body such as{ name1: "value1&", name2: "value2" }
sends the HTTP data as:name1=value1&&name2=value2
. This is because the RxJs Ajax code does not URL encode values when converting a object body content to string payload.