首页 > 解决方案 > 无法将 react-native 应用程序(博览会)与烧瓶服务器连接

问题描述

我正在尝试将我的 expo-app 与烧瓶服务器连接

这是请求

 fetch("127.0.0.1:5000/post", {
            method: 'POST',
            body: {
                'base64' : photoData["base64"]
            },
        })
        .then(response => response.json())
        .then(result => {
            console.log("******************\nRESULT");
            console.log(result);
            })
        .catch(err => { console.log(err); })

在服务器端。我已经尝试使用邮递员发送请求并且一切正常。

@app.route('/post', methods=['Post'])
def webhook():
    file = request.args['base64']
    rv = base64.b64encode(str.encode(file))  # bytes
    rv = rv.decode('ascii')  # str
    return rv

这是我在世博会上遇到的错误

Network request failed
- node_modules\whatwg-fetch\dist\fetch.umd.js:535:17 in setTimeout$argument_0
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:383:16 in callTimers
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
* [native code]:null in callFunctionReturnFlushedQueue

有谁知道解决方案?

标签: pythonreact-nativeflaskexpo

解决方案


推荐阅读