2017-03-05 2 views
2

express.js을 사용하여 로컬 서버를 설정했습니다. 간단히 요청을 처리하고 간단한 메시지를 반환합니다.처리되지 않은 약속 거부 네트워크 오류가 있습니다.

app.get('/hello', (req, res) => { 
    res.send('Hello world !'); 
}); 

서버를 실행하고 웹 브라우저에서 테스트 해 보면 잘 작동합니다.

단순히 내 react-native 앱에서 그렇게하고 싶습니다.

이 그것은 단지 catch() 결과를 반환 내 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); 
      }); 
    }; 
}; 

입니다.

Possible Unhandled Promise Rejection (id: 0): Network Error Error: Network Error at createError ...

잘못

enter image description here

어쩌면 뭔가하지만 난 그게 무엇을 찾을 수 없습니다.

어떻게 해결할 수 있습니까?

답변

관련 문제