Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

set auth header on axios instance

import axios from 'axios';

// use a middleware to intercept this action and pull token
// axios will automatically include header in all http requests

export function setToken(token) {
  axios.defaults.headers.common['Authorization'] =
      `Bearer ${token}`;
}
Source by daveceddia.com #
 
PREVIOUS NEXT
Tagged: #set #auth #header #axios #instance
ADD COMMENT
Topic
Name
5+4 =