-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from DeadSpoon18/feature/githubIssue
Create Issue on this repo using Github API.
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const express = require("express"); | ||
const fetch = require("node-fetch"); | ||
const router = express.Router(); | ||
|
||
router.post("/", async (req, res) => { | ||
try { | ||
const token = req.body.gitToken; | ||
const url = "https://api.github.com/repos/AasthaGithub/Elemento/issues"; | ||
const headers = { | ||
"Authorization": `Token ${token}`, | ||
}; | ||
const payLoad = { | ||
title: req.body.title, | ||
body: req.body.body, | ||
}; | ||
const response = await fetch(url, { | ||
method: "POST", | ||
headers: headers, | ||
body: JSON.stringify(payLoad), | ||
}); | ||
const result = await response.json(); | ||
res.json({ message: "Issue created." }); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}); | ||
|
||
module.exports = router; |