Signed-off-by: Max Schmidt <max.schmidt@outlook.de>
This commit is contained in:
Max Schmidt 2023-05-17 18:47:10 +02:00
parent ef3b65b1c0
commit a321c27376
2 changed files with 16 additions and 13 deletions

View File

@ -16,7 +16,6 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"express": "^4.17.1", "express": "^4.17.1",
"node-fetch": "^3.3.1",
"payload": "^1.8.2" "payload": "^1.8.2"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,5 +1,4 @@
import { CollectionConfig } from "payload/types"; import { CollectionConfig } from "payload/types";
import fetch from "node-fetch";
const Posts: CollectionConfig = { const Posts: CollectionConfig = {
slug: "posts", slug: "posts",
admin: { admin: {
@ -14,18 +13,23 @@ const Posts: CollectionConfig = {
hooks: { hooks: {
afterChange: [ afterChange: [
async () => { async () => {
console.log("HALLO");
try { try {
await fetch("https://api.github.com/repos/mooxl/astroad/dispatches", { console.log(
method: "POST", await fetch(
headers: { "https://api.github.com/repos/mooxl/astroad/dispatches",
Accept: "application/vnd.github.everest-preview+json", {
Authorization: "token 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", method: "POST",
}, headers: {
body: JSON.stringify({ Accept: "application/vnd.github.everest-preview+json",
event_type: "payload_update", Authorization:
}), "token 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",
}); },
body: JSON.stringify({
event_type: "payload_update",
}),
}
)
);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }