eastern-cyan2y ago

How do I pass an authorization header to @pankod/refine-simple-rest for API calls

Hello I am trying to use the @pankod/refine-simple-rest data provider, and the API endpoint requires the use of an Authorization header. Do I need to write a new provider or is there some way to monkey patch the axios instance inside the provider? Where would be the best place to do this? https://github.com/refinedev/refine/blob/next/packages/simple-rest/src/provider.ts I need something like: { headers: {"Authorization" : Bearer ${tokenStr}}
refine/provider.ts at next · refinedev/refine
Build your React-based CRUD applications, without constraints. - refine/provider.ts at next · refinedev/refine
2 Replies
optimistic-gold2y ago
Hi @hortinstein, you can use custom data provider. you can swizzle simple-rest and you can customize it according to your needs how to swwizle : https://refine.dev/docs/packages/documentation/cli/#swizzle or you can give your axiosInstance to refine-simple-rest https://refine.dev/docs/api-reference/core/providers/auth-provider/#setting-authorization-credentials
eastern-cyan2y ago
thank you both, I searched for a while but didn't come across either of these pages, really appreciate the help!