We can see how to use Axios in an optimized and scalable way in a React app.
When you are building an API-based React app, an HTTP client is the c...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
This is truly useful. Thanks a lot.
What is the need for
then(response => response)
on each method? Did you intend to extractdata
from the response so the consumer doesn't have to grabdata
each time? Such asreturn axiosClient.get(
/${URL}).then(response => response.data);
? Otherwise it could be removed to shorten those wrapper/helper methods.To access the response like below
What happens when you remove
.then(response => response)
fromgetRequest(URL)
. Does it change howconst user = await getRequest('users');
works at all?So good 🙏
super useful, thanks
sweet thank you
Awesome
I recommend using fetch everywhere, as axios can become bundle bloat for UIs. You just don't need it, really.
exactly you are correct, but how we can use interceptor in fetch ?
personally I like to use fetch
Awesome
Great article 👏👏
Amazing article. Super useful. Thank you ! ;-)