react axios request ... error status 500
-
here's my code:
let objconfig = {
'headers': {
'Content-Type': 'application/json'
},
'body': {
'template': { 'shortid': 'SJZLOZiSE' },
'data' : response.data
}
}return axios.post('http://14gise:5488/api/report', objconfig) .then((resp) => { this.setState({ isWebRptLoading: false }); let a = window.open(); a.document.open(); a.document.write(resp); }) .catch((error) => { console.log('axios error: ' + error); });
i keep getting an error that says Internal Server Error 500
and the response message says "could not parse report template, aren't you missing content type?"any ideas what i'm doing wrong? my header does contain content-type and everything looks right....
-
hi! please check axios post method docs, it looks like the second params of .post should be the data, not the whole config. change your call to:
axios.post('http://14gise:5488/api/report', { template: { shortid: 'SJZLOZiSE' } , data: response.data }, { 'headers': { 'Content-Type': 'application/json' } })
-
thank you!!! i never thought about checking if axios had a different implentation! :D