Redux axios查询字符串thunk+;图形ql

Redux axios查询字符串thunk+;图形ql,redux,graphql,axios,ngrok,thunk,Redux,Graphql,Axios,Ngrok,Thunk,我从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 XMLHttpReques

我从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
问题在于我的axios请求,而不是我的graphql模式,因为我能够用(我的ngrok url)/graphiql和localhost/graphql完成这个变异。我的查询对于axios或其他东西来说是否太长?我已经记录了我输入的所有信息,并且都是正确的格式,但同样,这些信息甚至没有进入我的服务器。另外,data.data.newMeeting看起来很奇怪,但这一部分实际上是正确的。这是我的心声:

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)
    }
  }
}

400表示您的查询格式不正确或无效。您可以查看服务器的实际响应(
error.response.data
)以查看出现了什么问题。如果让我猜的话,我会说这可能是你注入的价值观之一。不应该对动态值使用字符串插值。改为使用变量,这样可以确保正确解析值。谢谢,你是正确的!