wendux / fly

:rocket: Supporting request forwarding and Promise based HTTP client for all JavaScript runtimes.
https://wendux.github.io/dist/#/language
MIT License
3.9k stars 639 forks source link

支持拦截fetch请求吗 #267

Open dahai300 opened 4 years ago

dahai300 commented 4 years ago

支持拦截fetch请求吗

xdoer commented 3 years ago
const originFetch = globalThis.fetch

globalThis.fetch = function (url, opt) {
 // 修改参数
    const res = await originFetch(url, opt)
   // 利用这个修改响应 https://developer.mozilla.org/zh-CN/docs/Web/API/ReadableStream
    return res.clone()
}