I am using the Fetch API built into ZombieJS at the moment and am currently trying to send a post request to a URL stored as a variable (in my code it is labeled as "link"). When I display the output of the post request, I see the status code is 404
. The thing is I know the link exists and can verify through visiting it in a browser.
When I remove replace body: JSON.stringify(payload)
with body: payload
I get an error saying the body type is not supported. Can somebody tell me what I am doing wrong?
payload = {
'name': 'test',
'test2': 'abcd'
}
response = await browser.fetch(link, {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
});
console.log(response);