【发布时间】:2017-06-01 05:40:09
【问题描述】:
这是我的代码。
我正在调用以下函数来获取状态列表。
callGetStatesApi()
{
callGetApi(GLOBAL.BASE_URL + GLOBAL.Get_States)
.then((response) => {
// Continue your code here...
stateArray = result.data
Alert.alert('Alert!', stateArray)
});
}
这是从 GET Api 获取响应的常用 callGetApi 函数。
export function callGetApi(urlStr, params) {
return fetch(urlStr, {
method: "GET",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
})
.then((response) => response.json())
.then((responseData) => {
result = responseData
})
.catch((error) => {
console.error(error);
Alert.alert('Alert Title failure' + JSON.stringify(error))
});
}
我收到以下错误。
【问题讨论】:
标签: json reactjs parsing react-native