我正在构建一个非常简单的api和react-native应用程序.服务器运行良好(使用PostMan测试)但应用程序不会调用服务器.当axios必须发送帖子请求时它会阻止(见下文).
我很绝望:-(在这里度过太多时间.请,如果你能帮助我...
这是我的代码LogIn页面.它派遣动作创建者(使用redux)给出电子邮件和密码:
...
const LogIn = React.createClass({
submitLogin() {
// log in the server
if (this.props.email !== '' && this.props.psw !== '') {
if (this.props.valid === true) {
this.props.dispatch(logIn(this.props.email, this.props.psw));
} else {
this.props.dispatch(errorTyping());
}
}
},
...
Run Code Online (Sandbox Code Playgroud)
电子邮件和密码被检索并发送给动作创建者:
import axios from 'axios';
import { SIGNIN_URL, SIGNUP_URL } from '../api';
// import { addAlert } from './alerts';
exports.logIn = (email, password) => {
return function (dispatch) {
console.log(email);
console.log(password);
console.log(SIGNIN_URL);
return axios.post(SIGNIN_URL, { email, password })
.then(
(response) => …Run Code Online (Sandbox Code Playgroud) 我正在创建一个react-native应用程序,我创建的其中一个组件包含一个属性,该属性通过来自http请求的数据填充.
现在我正在从我的笔记本电脑托管服务器,但是我正在使用Expo应用程序在手机上测试应用程序.由于这些是两个独立的设备,http:// localhost:3000调用不起作用,因此我无法判断我的组件是否正常工作.
有没有办法在我的笔记本电脑上运行服务器并进行设置,以便来自Expo应用程序的http请求到达服务器?