A front-end request error is reported

Monitoring a FETCH request You can listen on a FETCH globally and intercept a FETCH request

const global = window; const _gFetch = global.fetch; global.fefch = function (... args) { return new Promise(resolve => { _gFetch.apply(this, Args).then((response) => {if (response.status === 200) {resolve(response.json())} else The error reporting method depends on the service. Console. log(" error !!!! Haha!!" )}})})}Copy the code

Here, by using Promise, the.then method can still be used to fetch the data returned by the server after the fetch succeeds.