4. FETCH VS XHR
FETCH VS XHR
Pros
promise rst
isomorphic(xhr and http in axios)
Cons
fetch can not abort and terminate or
implement onTimeout functionality(Can be
achieved with the experimental feature
AbortController)
no upload and download progress
20. RECAP
RECAP
umi-request uses fetch instead of xhr so progress
and true cancellation are not supported natively.
umi-request strings the entire request process
through the promise and onion model, the execute
order is req-interceptors -> custom middleware ->
default middleware -> global middleware -> core
middleware -> response interceptor(core fetch
middleware) -> errorHandler(any promise before
errorHandler reject will enter).
The extensions of umi-request are recommended
to be extended through Middleware. Reason: pure,
easy to test.
21. After replacing the core Middleware, the logic of
response interceptors needs to be compatible.