-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23c3a17
commit 41c9d89
Showing
3 changed files
with
13 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
export const apiConnector = async (method, url, bodyData, headers, params) => { | ||
const options = { | ||
method: method, | ||
headers: headers || {}, | ||
body: JSON.stringify(bodyData) || null, | ||
}; | ||
import axios from 'axios' | ||
|
||
if (params) { | ||
url += "?" + new URLSearchParams(params).toString(); | ||
} | ||
export const axiosInstance = axios.create({}) | ||
|
||
try { | ||
const response = await fetch(url, options); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
return await response.json(); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
} | ||
}; | ||
export const apiConnector = (method, url, bodyData, headers, params) => { | ||
return axiosInstance({ | ||
method: `${method}`, | ||
url: `${url}`, | ||
data: bodyData || null, | ||
headers: headers || null, | ||
params: params || null, | ||
}) | ||
} |