reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

Setting content-type to 'application/json' on POST seems to be broken

Open nicbarker opened this issue 7 years ago • 2 comments

Hi, I'm not sure if this repo is still maintained, but I can't seem to manage to set the request Content-Type header to application/json. The following code results in it being set to application/x-www-form-urlencoded:

reqwest({
    method: 'POST',
    url: url,
    withCredentials: true
    data: JSON.stringify(data),
    type: 'json',
    crossOrigin: true,
    contentType: 'application/json',
    headers: { 'Content-Type': 'application/json' }
})

This is in Chrome OSX, 54.0.2840.98. Any ideas?

nicbarker avatar Dec 18 '16 23:12 nicbarker

it seems to work:

contentType: 'application/json',
data: JSON.stringify(data),
processData: false,

ottaviano avatar Sep 24 '19 12:09 ottaviano