You've already forked NitroSniper
mirror of
https://github.com/neoarz/NitroSniper.git
synced 2026-05-11 13:15:37 +02:00
29 lines
789 B
TypeScript
29 lines
789 B
TypeScript
import { IpcMainInvokeEvent } from "electron";
|
|
|
|
import type { NativeWebhookResponse } from "./types";
|
|
|
|
export async function sendWebhook(_: IpcMainInvokeEvent, webhookUrl: string, payload: string): Promise<NativeWebhookResponse> {
|
|
try {
|
|
const url = new URL(webhookUrl);
|
|
url.searchParams.set("wait", "true");
|
|
|
|
const response = await fetch(url, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: payload
|
|
});
|
|
|
|
return {
|
|
status: response.status,
|
|
data: await response.text()
|
|
};
|
|
} catch (error) {
|
|
return {
|
|
status: -1,
|
|
data: error instanceof Error ? error.message : String(error)
|
|
};
|
|
}
|
|
}
|