I am getting the following error from an axios thunk:
ExceptionsManager.js:82 messed up in createMeeting: Error: Request failed with status code 400
at createError (createError.js:16)
at settle (settle.js:17)
at XMLHttpRequest.handleLoad (xhr.js:59)
at XMLHttpRequest.dispatchEvent (event-target.js:172)
at XMLHttpRequest.setReadyState (XMLHttpRequest.js:572)
at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:394)
at XMLHttpRequest.js:507
at RCTDeviceEventEmitter.emit (EventEmitter.js:189)
at MessageQueue.__callFunction (MessageQueue.js:366)
at MessageQueue.js:106
The problem is with my axios request and not with my graphql schema, because I am able to complete this mutation with (my ngrok url)/graphiql and also localhost/graphql. Is my query too long for axios or something? I've consoled logged all the information that I am inputting and it is all in the correct format, but again, the information is not even making it to my server. Also, the data.data.newMeeting looks weird, but that part is actually correct. Here is my thunk:
export const createMeeting = (chatId, userId, invitation) => {
return async dispatch => {
try {
const dateString = invitation.date.toDateString()
let {data} = await axios({
url: `${url}/graphql`,
method: 'POST',
data: {
query: `mutation{
newMeeting(chatId:${chatId},
userId:${userId},
latitude:${invitation.coords[0]},
longitude:${invitation.coords[1]},
name:"${invitation.name}",
rating:${invitation.rating},
address:"${invitation.address}",
date:"${dateString}"){
location
name
rating
date
senderId
chatId
}
}`
}
})
dispatch(setCurrentMeeting(data.data.newMeeting))
clearInvitation()
} catch (error) {
console.error('messed up in createMeeting: ', error)
}
}
}