【发布时间】:2022-12-20 04:27:22
【问题描述】:
when put token value as hardcoded it's work properly,but when i got token from asyncstorage and pass token in headers i got this error
Response not sucessful:Recevied status code 500 What is wrong in mycode?
import { ApolloClient,ApolloProvider,InMemoryCache,gql } from '@apollo/client'
import { createUploadLink } from 'apollo-upload-client'
const getToken = async () => {
const token = await AsyncStorage.getItem('@storage_Key')
return token
}
const token = getToken()
const client = new ApolloClient({
link: createUploadLink({
uri: 'http://192.168.1.82:8080/graphql',
headers: {
authorization: token
}
}),
cache: new InMemoryCache()
})
当我在标题中添加授权时,我得到了这个错误:响应不成功:收到状态代码 500 在 React native 中,否则它工作得很好。这里有什么问题?
【问题讨论】:
标签: react-native graphql