Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Axios GET Req with Basic Auth and Error

const err = await axios.
  get('https://httpbin.org/basic-auth/foo/bar', {
    auth: {
      username: 'foo',
      password: 'baz' // Bad password
    }
  }).
  catch(err => err);
err.message; // "Request failed with status code 401"
err.response.status; // 401 "Unauthorized"
Source by masteringjs.io #
 
PREVIOUS NEXT
Tagged: #Axios #GET #Req #Basic #Auth #Error
ADD COMMENT
Topic
Name
8+1 =