feat(medusa-js): add axios adapter to config (#6214)
**What** - Adds the ability to pass an Axios adapter through the client's config. **Why** - When using NextJS with the edge runtime for deployment on Cloudflare Pages, for example, Axios does not work. Therefore, it is necessary to pass an adapter like [@vespaiach/axios-fetch-adapter](https://github.com/vespaiach/axios-fetch-adapter). **How** - Receives the **axiosAdapter** in the config and implements it when creating the **axiosClient**. Closes #6133
This commit is contained in:
1 parent
7b30512a65
commit
bf1125209a
1 file changed
+8
-1
@@ -1,4 +1,9 @@
|
||||
import axios, { AxiosError, AxiosInstance, AxiosRequestHeaders } from "axios"
|
||||
import axios, {
|
||||
AxiosAdapter,
|
||||
AxiosError,
|
||||
AxiosInstance,
|
||||
AxiosRequestHeaders,
|
||||
} from "axios"
|
||||
import * as rax from "retry-axios"
|
||||
import { v4 as uuidv4 } from "uuid"
|
||||
|
||||
@@ -18,6 +23,7 @@ export interface Config {
|
||||
apiKey?: string
|
||||
publishableApiKey?: string
|
||||
customHeaders?: Record<string, any>
|
||||
axiosAdapter?: AxiosAdapter
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,6 +186,7 @@ class Client {
|
||||
createClient(config: Config): AxiosInstance {
|
||||
const client = axios.create({
|
||||
baseURL: config.baseUrl,
|
||||
adapter: config.axiosAdapter,
|
||||
})
|
||||
|
||||
rax.attach(client)
|
||||
|
||||
Reference in new issue
Block a user