Skip to content

Commit

Permalink
Merge pull request TEAM-BEAT#292 from tonyfromundefined/patch-1
Browse files Browse the repository at this point in the history
refactor: remove qs and replace with URLSearchParams Web API
  • Loading branch information
pepperdad authored Jul 23, 2024
2 parents d70f0d8 + 5f40cae commit b6cd8ff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"lottie-react": "^2.4.0",
"postcss": "^8.4.38",
"postcss-scss": "^4.0.9",
"qs": "^6.12.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-lottie-player": "^2.0.0",
Expand Down
9 changes: 6 additions & 3 deletions src/apis/domains/files/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { get } from "@apis/index";
import axios, { AxiosResponse } from "axios";
import qs from "qs";

interface ImageInterface {
[key: string]: string;
Expand Down Expand Up @@ -31,9 +30,13 @@ export const getPresignedUrl = async (
const response: AxiosResponse<PresignedResponse> = await get("/files/presigned-url", {
params: paramsWithEmptyArrays,
paramsSerializer: (params) => {
const queryString = qs.stringify(params, { arrayFormat: "repeat" });
const searchParams = new URLSearchParams();

const modifiedQueryString = queryString
for (const [k, v] of Object.entries(params)) {
searchParams.set(k, v);
}

const modifiedQueryString = searchParams.toString()
.replace(/castImages=%5B%5D/g, "castImages")
.replace(/staffImages=%5B%5D/g, "staffImages");
return modifiedQueryString;
Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4914,7 +4914,6 @@ __metadata:
postcss-styled-syntax: "npm:^0.6.4"
prettier: "npm:^3.3.2"
prettier-linter-helpers: "npm:^1.0.0"
qs: "npm:^6.12.3"
react: "npm:^18.3.1"
react-dom: "npm:^18.3.1"
react-lottie-player: "npm:^2.0.0"
Expand Down Expand Up @@ -9804,15 +9803,6 @@ __metadata:
languageName: node
linkType: hard

"qs@npm:^6.12.3":
version: 6.12.3
resolution: "qs@npm:6.12.3"
dependencies:
side-channel: "npm:^1.0.6"
checksum: 10c0/243ddcc8f49dab78fc51041f7f64c500b47c671c45a101a8aca565d8537cb562921da7ef1a831b4a7051596ec88bb35a0d5e25a240025e8b32c6bfb69f00bf2f
languageName: node
linkType: hard

"queue-microtask@npm:^1.2.2":
version: 1.2.3
resolution: "queue-microtask@npm:1.2.3"
Expand Down

0 comments on commit b6cd8ff

Please sign in to comment.