The first axios.get is getting data from local server and then pass into axios.post into 3rd party server.
If i pass 'data' (hardcoded) into axios.post, 3rd party server send back response as success operation, but if i use 'data1' from axios.get, they send back respond that something error/not valid in my data, which actually, hardcoded 'data' = 'data1' as a result axios.get.
Where is something wrong in my code?
const catalog = async (req, res) => {
const result = await axios.get('http://localhost:3500/catalog/SM-P6010ZKEXSE')
const data1 = JSON.stringify(result.data)
const data =
{"Catalogues":[{"siteCode":"","modelCode":"SM-P6010ZKEXSE","modelDesc":"Tablet SM-601 BLACK XSE E2014","datelist":[{"price":7450000,"status":"A","startDate":"20230509100316","endDate":"20240508100316"}]}]}
const header = {
"headers": {
"Authorization": "Bearer xyz",
}
}
try {
const result = await axios
.post('https://external-server/catalog', data , header)
{
console.log('Update catalog success')
console.log('status : ' + result.status)
console.log(result.data)
res.json(result.data)
}
} catch (error) {
console.log('Failed to update catalog')
}
}