-
Notifications
You must be signed in to change notification settings - Fork 3
/
test2.js
29 lines (24 loc) · 839 Bytes
/
test2.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
const fetch = require("node-fetch");
const BACKEND_URL = "http://localhost:8055";
const REFRESH_TOKEN =
"GBBhk-eY8783dQxmvLLbbc9Xb5Cs-470oY2yEiOd6rvJBJyjUPawmnjIOECCf72E";
async function testLogout() {
try {
console.log("Sending logout request...");
const response = await fetch(`${BACKEND_URL}/auth/logout`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ refresh_token: REFRESH_TOKEN }),
});
console.log("Response status:", response.status);
if (response.status === 204) {
console.log("Logout successful");
} else {
const responseText = await response.text();
console.error("Unexpected response:", response.status, responseText);
}
} catch (error) {
console.error("Error during logout:", error);
}
}
testLogout();