Skip to content

Instantly share code, notes, and snippets.

@KMJ-007
Created December 23, 2024 06:29
Show Gist options
  • Save KMJ-007/18d8824b88ddff6f4f45540166ac318b to your computer and use it in GitHub Desktop.
Save KMJ-007/18d8824b88ddff6f4f45540166ac318b to your computer and use it in GitHub Desktop.
export const axiosParamsSerializer: AxiosRequestConfig["paramsSerializer"] = (params) => {
const newParams = [];
for (const k in params) {
if (params[k] === undefined) {
continue;
}
if (Array.isArray(params[k]) || typeof params[k] === "object") {
newParams.push(`${k}=${encodeURIComponent(JSON.stringify(params[k]))}`);
} else {
newParams.push(`${k}=${encodeURIComponent(params[k])}`);
}
}
return newParams.join("&");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment