forked from GitHub-Coding-Challenge/devopsdaysams-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
20 lines (17 loc) · 659 Bytes
/
utils.js
File metadata and controls
20 lines (17 loc) · 659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const fetch = require("node-fetch");
const utils = {
// Invoke the API to post a quote to the Zen wall
// baseUrl: base URL of the API
// repoUrl: the URL to the GitHub repository, passed as a query parameter to the API endpoint
addToWall: async function (baseUrl, repoUrl) {
const response = await fetch(`${baseUrl}?repoUrl=${repoUrl}`, { method: 'POST' });
const message = await response.text();
if (response.status != 200) {
throw new Error(
`Received ${response.status} status code. Reason: ${message}`
);
}
return message;
}
};
module.exports = utils;