尝试使用Axios在本地反应上获取请求本地主机,但收到未处理的承诺拒绝:错误:网络错误

时间:2019-02-15 20:04:21

标签: reactjs request axios native es6-promise

在console.log中收到错误

[14:02:02] [未处理的承诺被拒绝:错误:网络错误] -createError中的node_modules \ axios \ lib \ core \ createError.js:16:24 -handleError中的node_modules \ axios \ lib \ adapters \ xhr.js:87:25 -... 9个来自框架内部的堆栈框架

import React, { Component } from 'react';
import { View, Text } from 'react-native';
import axios from 'axios';
import PhotoSection from './photo-section';
//functional is just returning some data - static
//smart component for dynamic class component
export default class PhotoFeed extends Component {

  render() {
      axios.get('http://127.0.0.1:3000/photos')
        .then(response=> console.log(response));
      return (
      <View>
        <Text> textInComponent </Text>
      </View>
    );
  }
}

0 个答案:

没有答案