首页 > 解决方案 > HTTPS 请求在 ios simualtor 上不起作用

问题描述

我在 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
}

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

标签: javascriptxcodereact-nativefetchexpo

解决方案


推荐阅读