This commit is contained in:
22
server.js
22
server.js
@@ -45,13 +45,21 @@ app.post("/report", async (req, res) => {
|
||||
|
||||
console.log(url)
|
||||
|
||||
const resp = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "text/plain",
|
||||
},
|
||||
body: `${content}\n\nClass: ${className}\nLocation: ${location}`,
|
||||
});
|
||||
let resp;
|
||||
|
||||
try {
|
||||
resp = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "text/plain",
|
||||
},
|
||||
body: `${content}\n\nClass: ${className}\nLocation: ${location}`,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Fetch failed:', err.message);
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!resp.ok) {
|
||||
throw new Error(`Request failed`);
|
||||
|
||||
Reference in New Issue
Block a user