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");
|
||||
import { logger } from "../utils/logger.utils";
|
||||
|
||||
@ -20,25 +19,29 @@ async function processor(data) {
|
||||
}
|
||||
|
||||
async function sendToGitea(body) {
|
||||
let key = process.env.OWL_GIT_ISSUEBOT;
|
||||
let url = process.env.OWL_GIT_APIENDPOINT;
|
||||
let opts = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: key,
|
||||
},
|
||||
body: body,
|
||||
};
|
||||
//var res = await axios.post(url, body, 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) {
|
||||
logger.info("issueService.sendToGitea: Issue sent to Gitea");
|
||||
return { status: res.status, message: "issue created" };
|
||||
} else {
|
||||
logger.error(res.body, "issueService.sendToGitea: Fail to send issue");
|
||||
return { status: res.status, message: "issue not created" };
|
||||
try {
|
||||
const key = process.env.OWL_GIT_ISSUEBOT;
|
||||
const url = process.env.OWL_GIT_APIENDPOINT;
|
||||
const opts = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: key,
|
||||
},
|
||||
body: body,
|
||||
};
|
||||
|
||||
const res = await fetch(url, opts);
|
||||
|
||||
if (res.status === 201) {
|
||||
logger.debug("issueService.sendToGitea: Issue created");
|
||||
return {status: res.status, message: "issue created"};
|
||||
} else {
|
||||
logger.error(`issueService.sendtoGitea: Error creating issue RETURN: ${res.status}`);
|
||||
return {status: res.status, message: "issue not created"};
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(err, `issueService.sendToGitea`);
|
||||
return {status:500, message: "Internal Server Error"};
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user