infinitered / apisauce

Axios + standardized errors + request/response transforms.
MIT License
2.78k stars 184 forks source link

QUESTION: How to set header on a new baseURL that was set #289

Closed abisalde closed 2 years ago

abisalde commented 2 years ago

Default baseURL

import {create} from 'apisauce';

const apiClient = create({
  baseURL: 'https://192.168.152.10/api',
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
});

export default apiClient;

NewBase URL const newApi = apiClient.setBaseUrl('https://192.168.152.20/api') const newHeader = newApi.setHeader('Authorization', 'token here'); // Error as I can use the call for AxiosInstance

How can I go about setting Header for the newApi.

absmugz commented 2 years ago

@abisalde try reading on this thread, you might get the info you need : https://github.com/infinitered/apisauce/issues/129

absmugz commented 2 years ago

@abisalde I am going to close this as an issue as its more to do with proper way of doing things instead of an issue with the package