HTTPS 请求不适用于 ios simualtor

时间:2021-08-01 14:43:57

标签: javascript xcode react-native fetch expo

我在 react-native 中完成了我的应用程序的编码,并且在 expo 应用程序中一切正常(我可以登录并使用该应用程序)但是当我构建应用程序并在 xcode 中启动它时,我的 HTTPS 请求似乎没有工作。卡在加载模式,请求无效。

示例请求如下:

export const fetchUserLoginToken = async (props) => {
    let userCredentials = await fetch('https://xxxx', {
        method: 'POST',
        body: JSON.stringify({
            "username": `${props.username}`,
            "password": `${props.password}`
        }),
        headers: {
            'Content-Type': 'application/json',
        }
    })
        .then(data => data.json())
        .then(data => {
            return data
        })
    return userCredentials
}

有什么解决办法吗?提前致谢

0 个答案:

没有答案