Is Simple-rest made for auth ?
is simple rest made just for basic api calls? cause i m trying to implement auth and its forcing me to create axios instance which comes out of the box in simplerest
login method to the Authorization header of API calls. This is useful for more complex use cases such as refreshing tokens when they expire.@refinedev/simple-rest@refinedev/simple-restaxios.create()axiosInstance.interceptors.request.useimport axios, { AxiosRequestConfig } from "axios";
const axiosInstance = axios.create();
axiosInstance.interceptors.request.use((request: AxiosRequestConfig) => {
// Retrieve the token from local storage
const token = JSON.parse(localStorage.getItem("auth"));
// Check if the header property exists
if (request.headers) {
// Set the Authorization header if it exists
request.headers["Authorization"] = `Bearer ${token}`;
} else {
// Create the headers property if it does not exist
request.headers = {
Authorization: `Bearer ${token}`,
};
}
return request;
});