Basic auth with axios — NodeJS & browser
1 min readJul 20, 2020
Axios, like many other popular HTTP clients, has built-in support for basic auth. However, very often in code reviews, and while browsing stack overflow answers I run into implementations similar to this:
While there is nothing wrong with the code itself, there is a simpler way to achieve the same thing.
As you can see, the axios provides an elegant way to invoke APIs protected with basic auth, hiding away the base64 encoding and string concatenation.
If you liked this short post, check out my other axios related writings.