鍍金池/ 問答/Linux  HTML/ 使用fetch抓取數(shù)據(jù)的時候,控制臺出現(xiàn)紅叉,怎么處理才能不顯示紅叉

使用fetch抓取數(shù)據(jù)的時候,控制臺出現(xiàn)紅叉,怎么處理才能不顯示紅叉

import React, { Component } from 'react';
import fetch from 'isomorphic-fetch';

class DataSource extends React.Component {// 初始化模擬數(shù)據(jù)

    constructor(props) {
        super(props);

        this.state = {

            load:false,
            text:''
        };
    }

    //耗時操作放在這里面
    componentDidMount(){
        //this.getNet();
    }

    getNet(){
        fetch('http://gank.io/api/search/query/listview/category/福利/count/10/page/1')//請求地址
            .then((response) => response.json())//取數(shù)據(jù)
            .then((responseText) => {//處理數(shù)據(jù)
                //通過setState()方法重新渲染界面
                console.error(responseText)

            })
            .catch((err) => console.error(err));
    }

    render() {

            return (
                <div className="square" onClick={() => this.getNet()}>
                    獲取網(wǎng)絡(luò)內(nèi)容
                </div>
            );
        
    }
}

export default DataSource;

圖片描述

回答
編輯回答
熊出沒

你主動把正常的log變?yōu)閑rror我也沒辦法啊
console.error(responseText) => console.log(responseText)

2018年8月2日 02:07