This topic was automatically generated from Slack. You can find the original thread here.
i keep receiving error with this script :
import { axios } from “@pipedream/platform”;
export default {
name: “GitHub Issues Webhook”,
description: “Emit events for new GitHub issues”,
props: {
github: {
type: “app”,
app: “github”,
},
},
async run(event) {
const { action, issue } = event.body;
if (action === “opened”) {
this.$emit(issue, {
id: issue.id,
summary: ISSUE ${issue.number}: ${issue.title}
,
ts: +new Date(issue.created_at),
});
}
},
hooks: {
async activate() {
const repoOwner = “vikas-velora”;
const repoName = “slack-static”;
const webhookURL = ${this.http.endpoint}/webhook
;
// Create webhook on GitHub
await axios(this, {
method: "post",
url: `https://api.github.com/repos/${repoOwner}/${repoName}/hooks`,
headers: {
Authorization: `Bearer ${this.github.$auth.oauth_access_token}`,
Accept: "application/vnd.github.v3+json",
},
data: {
config: {
url: webhookURL,
content_type: "json",
secret: "your-webhook-secret", // Make sure to use a secure secret
},
events: ["issues"],
active: true,
},
});
},
async deactivate() {
// Remove webhook from GitHub
const repoOwner = "vikas-velora";
const repoName = "slack-static";
// List all webhooks and find the one we need to remove
const { data: hooks } = await axios(this, {
method: "get",
url: `https://api.github.com/repos/${repoOwner}/${repoName}/hooks`,
headers: {
Authorization: `Bearer ${this.github.$auth.oauth_access_token}`,
Accept: "application/vnd.github.v3+json",
},
});
const webhook = hooks.find(
(hook) => hook.config.url === `${this.http.endpoint}/webhook`
);
if (webhook) {
await axios(this, {
method: "delete",
url: `https://api.github.com/repos/${repoOwner}/${repoName}/hooks/${webhook.id}`,
headers: {
Authorization: `Bearer ${this.github.$auth.oauth_access_token}`,
Accept: "application/vnd.github.v3+json",
},
});
}
},
},
};