1const res = await axios.get('https://httpbin.org/basic-auth/foo/bar', {
2 // Axios looks for the `auth` option, and, if it is set, formats a
3 // basic auth header for you automatically.
4 auth: {
5 username: 'foo',
6 password: 'bar'
7 }
8});
9res.status; // 200
1// Send a GET request with the authorization header set to
2// the string 'my secret token'
3const res = await axios.get('https://httpbin.org/get', {
4 headers: {
5 'Authorization': 'my secret token'
6 }
7});