Chrome dev tools fails to show response even the content returned has header Content-Type:text/html; charset=UTF-8

后端 未结 9 1143
轮回少年
轮回少年 2020-12-12 11:25

Why does my chrome developer tools show \"Failed to show response data\" in response when the content returned is of type text/html?

What is the alternative to see t

9条回答
  •  无人及你
    2020-12-12 12:00

    For those coming here from Google, and for whom the previous answers do not solve the mystery...

    If you use XHR to make a server call, but do not return a response, this error will occur.

    Example (from Nodejs/React but could equally be js/php):

    App.tsx

    const handleClickEvent = () => {
        fetch('/routeInAppjs?someVar=someValue&nutherVar=summat_else', {
            method: 'GET',
            mode: 'same-origin',
            credentials: 'include',
            headers: {
              'content-type': 'application/json',
              dataType: 'json',
            },
        }).then((response) => {
            console.log(response)
        });
    }
    

    App.js

    app.route('/getAllPublicDatasheets').get(async function (req, res) {
        const { someVar, nutherVar } = req.query;
        console.log('Ending here without a return...')
    });
    

    Console.log will here report:

    Failed to show response data
    

    To fix, add the return response to bottom of your route (server-side):

    res.json('Adding this below the console.log in App.js route will solve it.');
    

提交回复
热议问题