【发布时间】:2020-07-02 13:06:31
【问题描述】:
为什么我得到输出 "\"userName\"" 而不是 "userName" ?
在我的示例中,我尝试做一个 get api,它附加一些数据并且该数据来自异步存储。
当我控制输出时,它会显示这样的数据:
"\"userName\""
但它应该输出 "userName" 。
解决这个问题的方法是什么?
所以我的方式有什么问题?
const getSaveUserTokenData = async (data) => {
const url =
'https://URL/userName,userToken,PlatformType,DeviceID?' +
'userName=' +
data.userName +
'&userToken=' +
data.googlToken +
'&PlatformType=' +
data.platformId +
'&DeviceID=' +
data.deviceId;
await fetch(
url,
{
method: 'GET',
headers: {
Authorization: data.azureToken,
},
}
)
.then((response) => response.json())
.then((data) => {
console.log('Success:', data);
})
.catch((error) => {
console.error('Error:', error);
});
};
【问题讨论】:
-
有什么问题?从理论上讲,这应该有效。假设您生成的 URL 是正确的。
标签: javascript reactjs react-native rest expo