React Native Client可以使用axios连接到Node.js后端

时间:2018-10-19 14:40:42

标签: node.js react-native axios expo

我尝试输入带有axios.post的电子邮件并将其发送到后端。它失败并显示:

Request failed with status code 500 node_modules\axios\lib\core\createError.js:16:24 in createError

我的代码:

_onPressButton61 = async () => {
    if (this.validate(this.state.userData.email)) {
        try {
            let result = await axios.post('http://192.168.1.4:3000/users', this.state.userData);

            this.props.navigation.navigate('Splash');
            console.log(result);
        }
        catch (err) {
            console.log(err);
            Alert.alert('This email was used');
        }
    }
    else {
        console.log("NU POTI TRECE");
        Alert.alert('This email is invalid');
    }

}

0 个答案:

没有答案