Reputation: 17383
I'm using fetch
to send value to my server. my server is php.
when I send my values with postman my server response as well.
but when I want to send my values with fetch I cannot get them from server side.
my requestOption:
const requestOptions = {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(parms)
};
my values sent to server but I cannot get them like postman form-data.
parms
is a object variable. like:
var parms = {};
parms['tok'] = '35345345';
Upvotes: 2
Views: 2588
Reputation: 4139
Just use formData
as fetch
body:
var formData = new FormData()
formData.append("tok", '35345345')
const requestOptions = {
method: 'POST',
headers: {
'Accept': 'application/json'
},
body: formData
};
Upvotes: 3