HTTP請(qǐng)求錯(cuò)誤

2019-02-20 15:38 更新

HTTP請(qǐng)求錯(cuò)誤在Fundebug控制臺(tái)的圖標(biāo)如下:

前端通過(guò)大量的API與后端進(jìn)行交互,這些API也有可能出錯(cuò)。

通常,后端會(huì)通過(guò)日志記錄所有HTTP請(qǐng)求,但是查詢起來(lái)非常不便,也不及時(shí)。Fundebug可以捕獲所有HTTP請(qǐng)求錯(cuò)誤,同時(shí)記錄用戶行為,并實(shí)時(shí)提醒開(kāi)發(fā)者,且不需要修改后端,也不需要搭建復(fù)雜的日志系統(tǒng)。

下面的示例中,登陸賬戶時(shí)密碼錯(cuò)誤,因此會(huì)報(bào)403錯(cuò)誤。

var xhr = new XMLHttpRequest();
xhr.open("POST", "https://api.fundebug.com/login");
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(
{
    email: "help@fundebug.com",
    password: "akhakfnak"
}));

開(kāi)發(fā)者可以在Fundebug控制臺(tái)錯(cuò)誤詳情:


Fundebug插件捕獲的錯(cuò)誤數(shù)據(jù)如下:

{
    "notifierVersion": "0.2.0",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0",
    "locale": "zh",
    "url": "http://localhost:4000",
    "title": "Test",
    "apiKey": "API-KEY",
    "time": 1502864518516,
    "type": "httpError",
    "req": {
        "method": "POST",
        "url": "https://www.fundebug.com/login"
    },
    "res": {
        "status": 403,
        "statusText": "Forbidden",
        "response": "{\"error\":\"wrong password\"}"
    }
}

HTTP請(qǐng)求錯(cuò)誤的type屬性值為httpError。

silentHttp

如果你不需要監(jiān)控HTTP請(qǐng)求錯(cuò)誤,則可以將silentHttp屬性設(shè)為true。


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)