Take the following Axios example:
axios.post(this.reportURL, reportData, {
params: {
param1: paramValue1,
param2: paramValue2
},
});
How can I do the same thing using fetch API? I see that parameters are done like this:
fetch(this.reportURL, {
method: "POST",
body: "param1=paramValue1¶m2=paramValue2",
headers:
{
"Content-Type": "application/x-www-form-urlencoded"
}
})
Since the body key is being used to store the parameters, do I need to serialize my entire reportData object and concatenate it to the existing parameters?
I don't understand why Fetch API is using the body key for parameters.
Additionally, this is not my own API and I cannot change the expected POST request.