umijs / umi-request

A request tool based on fetch.
2.2k stars 336 forks source link

[Question] why {...res} always get {} even if res is a validate Response #290

Open hanalice opened 2 years ago

hanalice commented 2 years ago

I put the following configuration in app.tsx, console always output {} which I expect extending response data with my customize data, but it doesn't work. What should I do to extend response data? And why does this happen?

export const request: RequestConfig = {
    responseInterceptors: [
        (res: Response) => {
            console.log(res.status);  // this line can get the right http status
            console.log({...res});  // this line will always output {}
            return res;
        },
    ],
};
hanalice commented 2 years ago

@clock157 @yesmeck @yutingzhao1991

hello, anyone can help?