refactor for query params
This commit is contained in:
parent
8b747f0a1e
commit
f45ae05380
1 changed files with 5 additions and 1 deletions
|
|
@ -121,7 +121,11 @@ async function request(url, options = {}, isRetry = false) {
|
|||
}
|
||||
|
||||
export const apiClient = {
|
||||
get: (url) => request(url, { method: 'GET' }),
|
||||
get: (url, params = {}) => {
|
||||
const queryString = new URLSearchParams(params).toString();
|
||||
const fullUrl = queryString ? `${url}?${queryString}` : url;
|
||||
return request(fullUrl, { method: 'GET' });
|
||||
},
|
||||
post: (url, data) => request(url, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue