Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Axios GET Req with Basic Auth

const res = await axios.get('https://httpbin.org/basic-auth/foo/bar', {
  // Axios looks for the `auth` option, and, if it is set, formats a
  // basic auth header for you automatically.
  auth: {
    username: 'foo',
    password: 'bar'
  }
});
res.status; // 200
Comment

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"
Comment

PREVIOUS NEXT
Code Example
Javascript :: display a div only seconds js 
Javascript :: how to filter multiple values from a json api 
Javascript :: audio customization 
Javascript :: react js charts with camvas 
Javascript :: create auto increment mongodb mongoose 
Javascript :: nodejs stream 
Javascript :: string to object js 
Javascript :: javascript event loop 
Javascript :: get search value from reacr route1 
Javascript :: Material-ui Accessibility icon 
Javascript :: Using An Array As A Parameter Of A Function 
Javascript :: deno vs node 
Javascript :: javascript got device ip 
Javascript :: in if condition how to set alert music in javascript 
Javascript :: google places autocomplete react native 
Javascript :: jquery find attribute from siblings 
Javascript :: javascript use class without instantiating 
Javascript :: javascript object properties 
Javascript :: useEfefct react 
Javascript :: vue state 
Javascript :: prevent a function from being called too many times react 
Javascript :: json parse 
Javascript :: react native fetch response code 
Javascript :: clock picker jquery 
Javascript :: reverse array in js 
Javascript :: react date range 
Javascript :: regex exact match 
Javascript :: Append to the text in the <p tag 
Javascript :: Jest DOM Manipulation 
Javascript :: could not decode base64 cloudinary 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =