Fix errornous headers field inoptions
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
a87f203782
commit
be9fb68c3d
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-useless-escape */
|
|
||||||
//const axios = require("axios");
|
//const axios = require("axios");
|
||||||
import { logger } from "../utils/logger.utils";
|
import { logger } from "../utils/logger.utils";
|
||||||
|
|
||||||
@ -20,26 +19,30 @@ async function processor(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function sendToGitea(body) {
|
async function sendToGitea(body) {
|
||||||
let key = process.env.OWL_GIT_ISSUEBOT;
|
try {
|
||||||
let url = process.env.OWL_GIT_APIENDPOINT;
|
const key = process.env.OWL_GIT_ISSUEBOT;
|
||||||
let opts = {
|
const url = process.env.OWL_GIT_APIENDPOINT;
|
||||||
|
const opts = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: key,
|
Authorization: key,
|
||||||
},
|
},
|
||||||
body: body,
|
body: body,
|
||||||
};
|
};
|
||||||
//var res = await axios.post(url, body, opts);
|
|
||||||
const res = await fetch(url, opts);
|
const res = await fetch(url, opts);
|
||||||
/* Need to read the output from the POST and pass the result upwards to the
|
|
||||||
client.*/
|
if (res.status === 201) {
|
||||||
if (res.status == 201) {
|
logger.debug("issueService.sendToGitea: Issue created");
|
||||||
logger.info("issueService.sendToGitea: Issue sent to Gitea");
|
|
||||||
return {status: res.status, message: "issue created"};
|
return {status: res.status, message: "issue created"};
|
||||||
} else {
|
} else {
|
||||||
logger.error(res.body, "issueService.sendToGitea: Fail to send issue");
|
logger.error(`issueService.sendtoGitea: Error creating issue RETURN: ${res.status}`);
|
||||||
return {status: res.status, message: "issue not created"};
|
return {status: res.status, message: "issue not created"};
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(err, `issueService.sendToGitea`);
|
||||||
|
return {status:500, message: "Internal Server Error"};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Loading…
Reference in New Issue
Block a user