You've already forked NitroSniper
mirror of
https://github.com/neoarz/NitroSniper.git
synced 2026-05-11 13:15:37 +02:00
feat: webhook support
This commit is contained in:
28
native.ts
Normal file
28
native.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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: String(error)
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user