Skip to content

Commit

Permalink
Add axios library for making HTTP requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Arejula11 committed Apr 3, 2024
1 parent 4baa107 commit 1c902b1
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 15 deletions.
91 changes: 91 additions & 0 deletions playbeat/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions playbeat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@types/react-dom": "^18.2.19",
"apexcharts": "^3.47.0",
"astro": "^4.4.0",
"axios": "^1.6.8",
"clsx": "^2.1.0",
"framer-motion": "^11.0.5",
"react": "^18.2.0",
Expand Down
28 changes: 13 additions & 15 deletions playbeat/src/utils/register.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { Global } from "@/globalState/globalUrl.js";
import axios from 'axios';

import {Global} from "@/globalState/globalUrl.js"
async function registerUser(data: { name: any; email: any; password: any; }) {
try {
console.log("Sending request with data:", data);
const response = await axios.post(Global.url + "auth/signup", data);

console.log("Response:", response.data);

async function registerUser(data: { name: FormDataEntryValue | null; email: FormDataEntryValue | null; password: FormDataEntryValue | null; }) {
try {
console.log(data);
const response = await fetch(Global.url+'auth/signup', {
method: 'POST',
body: JSON.stringify(data)
});
console.log(response);
return response;
} catch (error) {
throw new Error((error as Error).message);
}
return response.data;
} catch (error) {
console.error("Error registering user:", error);
throw error;
}
}

export {registerUser}
export { registerUser };

0 comments on commit 1c902b1

Please sign in to comment.