【发布时间】:2017-07-25 02:13:11
【问题描述】:
我使用express.js 设置我的本地服务器,它只是处理请求并返回简单的消息。
app.get('/hello', (req, res) => {
res.send('Hello world !');
});
我执行了服务器并在网络浏览器上对其进行了测试,它运行良好。
我只是想在我的 react-native 应用上这样做。
这是我的action.js 文件
import axios from 'axios';
exports.helloButtonPressAct = (email, password) => {
return function (dispatch) {
return axios.get('http://localhost:3000/hello')
.then(function (response) {
console.log(response);
// and create action obj here
// dispatch(someAction(...))
})
.catch(function (error) {
throw error;
console.log(error);
});
};
};
它只返回catch() 结果。
可能的未处理承诺拒绝(id:0):网络错误错误: createError 处的网络错误 ...
可能有问题,但我找不到问题所在。
我该如何解决这个问题?
【问题讨论】:
标签: react-native redux axios redux-thunk