why this post method is showing data: {key: "data"} ? Anyone ?
handleUpload() {
const companyuid = this.props.match.params.id;
var raw =
{
"data":[
{
"type": "CRN",
"value": this.state.cr_number,
"files": [this.state.UUID_CRN]
},
{
"type": "VRN",
"value": this.state.vat,
"files": [this.state.UUID_VAT]
},
{
"type": "CON",
"value": this.state.vat,
"files": [this.state.UUID_VAT]
}
]
};
let AUTH_TOKEN = window.localStorage.getItem("ACCESSTOKEN");
fetch(
"http://xxxx/documents",
{
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: Bearer ${AUTH_TOKEN}
},
body: JSON.stringify(raw)
}
)
.then(response => response.json())
.then(responseJson => {
console.log(responseJson);
})
.catch(error => console.log("error", error));
}
Top comments (5)
Is this error showing when you are parsing it back to JSON?
It's resolved .. Thanks for the reply though :)
how you solved it im also stucked on this
hello, sir, can you tell me how you solved it? i got stuck in this similar situation. Any kind of response from you would be much appreciated. Thank you!
Kindly post the solution so it can help others, like me too :)