Skip to content

Commit

Permalink
fix apiconnector issue
Browse files Browse the repository at this point in the history
  • Loading branch information
amitamrutiya committed Feb 12, 2024
1 parent 23c3a17 commit 41c9d89
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dependencies": {
"@ramonak/react-progress-bar": "^5.0.3",
"@reduxjs/toolkit": "^1.9.7",
"axios": "^1.6.7",
"chart.js": "^4.4.0",
"copy-to-clipboard": "^3.3.3",
"react": "^18.2.0",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/core/Auth/SignupForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ function SignupForm () {
name="contactNumber"
id="contactNumber"
value={contactNumber}
onChange={handleOnChange}
placeholder="12345 67890"
className="form-style bg-richblack-800 rounded-[0.5rem] text-richblack-5"
style={{
Expand Down
30 changes: 11 additions & 19 deletions frontend/src/services/apiconnector.js
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,
})
}

0 comments on commit 41c9d89

Please sign in to comment.