When I use axios.post(...).then(data=>callback(data)) the data is not defined when I access it in the callback, however, a console log right before the data is accessed shows all the data.
I've tried all the combinations of async await that's possible. I feel like this is a way simpler problem than I'm making it.
// passed in as successCallback
const handleCreationCompleted = data => {
console.log(data)
// Error below ReturnedDataObject not defined
var object = data.ReturnedDataObject
}
const createObject = async (variables, successCallback, errorCallback) => {
...
await axios.post(url, form_data, {
headers: {
...
},
}).then(res => {
successCallback(res)
})
.catch((err) => {
errorCallback(err)
})
I should be able to access the data, which is a json object (it's fetched from a graphql api) within the successcallback