Issue with Creating Multiple Labels
Example Code:
Promise.all(
srcRepoReq.data.map(async (label) => {
const newLabel: ghLabel = {
name: label.name,
color: label.color,
description: label.description,
};
const createLabelReq = await octokit.request('POST /repos/{username}/{trgtRepo}/labels', {
username: cfg.username,
trgtRepo: cfg.trgtRepo,
name: newLabel.name,
color: newLabel.color,
description: newLabel.description,
});
Terminal.writeInfo(createLabelReq.status);
Terminal.writeInfo(newLabel.name);
})
);
Goal:
I am trying to create multiple labels using the GitHub @octokit/core
API Client.
Challenge:
The promises in the code snippet do not seem to execute. I am not receiving any output from the Terminal.*
methods and no labels are being created in the repository. However, when I run the code outside of
Promise.all(srcRepoReq.data.map(...));
, it works perfectly fine and creates the labels as expected. But manually executing each request and hardcoding them is not a desirable solution. I want to create labels based on an array of elements.
Data Type:
type ghLabel = {
name: string;
color: string;
description: string;
};
This data structure contains all the necessary information for creating a label via the GitHub API.
Could this issue be related to any restrictions imposed by GitHub? Such as a limit on the number of requests per time interval?
Clarification
Yes, the types have been confirmed to be correct.