Getting Object Promise on axios call return function getWagon(para){
return (
axios.get('/op1_get_list/'+para).then((response) => {
return (response.data);
})
)
}
"Object Promise"
@muazzamazaz why are you returning response.data? Just use console.log(response.data) if you want to see it.
@SilenceBringer
async function getWagon(wagon){
return (await Promise.resolve(axios.get('/op1_get_wagon/'+wagon).then((response) => {
return (response.data.tankno);
})))
}
still same error
@muazzamazaz how about this
async function getWagon(wagon){
const response = await axios.get('/op1_get_wagon/'+wagon);
return response.data.tankno;
}
@muazzamazaz
the 'then()-> chaining is intended to use the response in a callback function, which mean pretty much that you would only use it right in that function and nowhere else
if you want to reuse the data, you must assign it to a variable:
let response = await axios.get('blablabla');
Please sign in or create an account to participate in this conversation.