Answers for "set auth header on axios instance"

0

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}`;
}
Posted by: Guest on March-25-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language