Reactjs 获取错误JSON解析错误:发送令牌获取数据时出现意外EOF*“;“反应自然”;
我试图发送令牌从API访问数据,但它给出错误“无法解析json”。Reactjs 获取错误JSON解析错误:发送令牌获取数据时出现意外EOF*“;“反应自然”;,reactjs,react-native,native,access-token,Reactjs,React Native,Native,Access Token,我试图发送令牌从API访问数据,但它给出错误“无法解析json”。 代码如下 componentDidMount() { const config = { headers: { Accept: "application/json", "Content-Type": "application/json", Authorizat
代码如下
componentDidMount() {
const config = {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: "Bearer" + AsyncStorage.getItem("token"),
},//sending token to access data but failed and got unable to parse json error
};
return fetch("http://dev11.11values.com/api/VoterList/getvoterlist", config)
.then((response) => response.json())
.then((responseJson) => {
this.setState(
{
isLoading: false,
dataSource: responseJson.Table,
},
function () {
this.arrayholder = responseJson;
}
);
})
.catch((error) => {
console.error(error);
});
}