Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ServiceApi = axios.create({
- baseURL: BASE_URL,
- responseType: 'json'
- });
- return {
- type: PERFORM_LOGIN,
- payload: {
- user: {
- name: username
- },
- request: {
- url: '/login',
- method: 'post',
- headers: {
- 'Authorization': 'Basic ' + basicAuth
- }
- }
- }
- // On login success, set the authInterceptor responsible for adding headers
- authInterceptor = ServiceApi.interceptors.request.use((config) => {
- console.log(`Attaching Authorization to header ${basicAuth}`);
- config.headers.common.Authorization = basicAuth;
- return config;
- }, (error) => {
- Promise.reject(error);
- });
- // Clear the auth interceptor
- ServiceApi.interceptors.request.eject(authInterceptor);
- _headers:
- accept: "application/json, text/plain, */*"
- authorization: "Basic <correct base64 value>"
- content-type: "application/json;charset=utf-8" __proto__: Object
- _headers:
- accept: (...)
- authorization: (...)
- content-type: (...)
- get accept: ƒ ()
- set accept: ƒ ()
- get authorization: ƒ ()
- set authorization: ƒ ()
- get content-type: ƒ ()
- set content-type: ƒ ()
- __proto__: Object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement