-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
31 lines (26 loc) · 908 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import axios from "axios";
axios.get("http://localhost:8000/").then(result => console.log(result));
let token =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiJ2YWliaGF2Z2FtaW5naWQxQGdtYWlsLmNvbSIsImV4cGlyeSI6MTY3ODUxOTg2NC45NjI0OTZ9.MkFwdzlE1_gY_yv8-j5FRowNnj5PS6VM9QCZ35A9Cb0";
const config = {
headers: { Authorization: `Bearer ${token}` },
};
// const bodyParameters = JSON.parse({
// name: "Vaibhav patel",
// email: "[email protected]",
// joinedAt: "2023-03-11T10:13:53.733628",
// profession: "teacher",
// password: "abcdefg",
// gender: true,
// });
axios
.post(
"http://localhost:8000/user/login",
{
email: "[email protected]",
password: "abcdefg",
},
config,
)
.then(result => console.log(result.data.data[0]["access token"]));
// above function returns access token