我的url=>http://180.100.200.202/api/files/upload

这是我的密码

uploadFiles({
        toUrl: "http://180.100.200.202/api/files/upload",
        files: files,
        method: "POST",
        headers: { Accept: "application/json" },
        begin: () => {
        },
        progress: ({ totalBytesSent, totalBytesExpectedToSend }) => {
            // console.log({ totalBytesSent, totalBytesExpectedToSend })
        },
    })
        .promise.then(_ => {
        })
        .catch(_ => {
            console.log(_)
})

当我调用上述代码时,我得到以下错误:

[Error: Failed to connect to /180.100.200.202:80]

这不是我的url.为什么会改变?

EDIT: It works perfectly in emulator but in cell phone does not.

推荐答案

确保您已连接到internet.我也有同样的问题,我意识到我没有连接,在我连接到互联网后,问题解决了

React-native相关问答推荐

'无法解析模块.安装react-native-pager-view后的实用程序/平台

react 本机函数不通过usContext触发

使用react-native-reanimatedreact 导航崩溃

React Native 动画.您必须在转换属性中精确指定一个属性.

如何渲染一个 svg 以在不同的窗口大小下动态地看起来相同?

react-native 自定义视图,原生 prop 没有 propType

按下按钮有一个borderRadius

从 React-Native 应用程序中的另一个类访问静态变量?

在根项目ReactNativeStarter中找不到任务installRelease

如何在 React Native 中创建和保存 CSV 文件?

如何在获取请求中传递 POST 参数?

React 中的 getSnapshotBeforeUpdate() 是什么?

React Native 使视图 Hug键盘顶部

使用 React Native 打开 iOS iPad 模拟器

如何隐藏 React Native NavigationBar

如何在 React Native 上隐藏 createStackNavigator 的标题?

React 本机矢量图标在当前版本 0.60 上不起作用

Super expression must either be null or a function, not undefined

如何允许 react-native 启用对 JSX(扩展)文件的支持

使用 TouchableWithoutFeedback react-native onPress 不起作用