Octokit: Unable to create multiple Labels at once

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.

Any Solutions?

Answer №1

It seems like the issue you are facing could be related to an abuse rate limit. Have you attempted to investigate why the Promise.all is failing and how many repositories might be causing it?

If you discover that you are hitting the API limit, I recommend utilizing Throttling Octokit's plugin (@octokit/plugin-throttling) as a solution.

In addition, I encourage you to explore Octoherd (created by the same individual behind Octokit). It includes a create-script-utility for managing tasks on repositories, such as handling labels in this scenario.

If you encounter any difficulties while using Octoherd or the Octokit Plugin, don't hesitate to open an issue on their respective repositories; the creator and other contributors are actively engaged there.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Upon calling set() on Map, the object returned does not conform to a Map data structure

I've been exploring the transition to using immutable.js for managing states: class Register extends Component<{}, Map<string, string>> { state = Map<string, string>(); onInputValueChange(e) { const { name, value } ...

Tips for sharing data between two components

In my project, I have a customized Shared Component which consists of an input search bar with a "continue" button. This Shared Component is being utilized within two other components - the buy component and sell component. The challenge I am encountering ...

Encountering a NullInjectorError in Angular while utilizing dynamic module federation when importing a standalone component along with

My main goal is to develop a shell application acting as a dashboard without routing, featuring multiple cards with remote content (microfrontend standalone component). I have been following a tutorial that aligns closely with my requirements: . The reas ...

Executing a series of HTTP requests sequentially using Angular 5

I need some guidance on sending an array of HTTP requests in sequential order within my application. Here are the details: Application Entities : Location - an entity with attributes: FanZone fanZone, and List<LocationAdministrator> locationAdmins ...

Unable to locate the necessary file. - Implementing TypeScript in a React application

Attempting to integrate TypeScript into an existing React app by following the steps outlined at: https://create-react-app.dev/docs/adding-typescript I've followed all the instructions but encountered the following error upon trying to launch the app ...

MXGraph has an issue where edges fail to be redrawn after being moved

Perhaps this question may seem trivial, but I am facing an issue in my code and seeking guidance from the community. I am working on a javascript mxGraph application within Angular7. Specifically, I have modified the ports.html example for my project. Wh ...

Is there a way to implement a pipe function in TypeScript?

Introducing a unique pipe function implemented in plain JavaScript: const customPipe = (f, ...fs) => x => f === undefined ? x : customPipe(...fs)(f(x)) const exampleFunction = customPipe( x => x + 1, x => `wow ${x * 2} this is an amaz ...

Utilizing React-hook-Form to transfer data between two SelectBoxes

This simple logic is causing me some trouble. Despite using react-hook-form, I thought this would be easy. However, after struggling with it for over a week, I'm still facing challenges. I'm incorporating nextUI components into my project. < ...

Retrieving a PHP value from a JSON string

Need help extracting the value from 'status' within a JSON Array named 'orders' { "orders": [ { "orderId": "F3MXBWMG61151028GUEST000P01", "orderCreateDate": "2015-10-28T09:2 ...

`How can TypeScript be used to designate the type of a variable within the useState hook?`

I defined a variable called 'text' and a hook named 'setText'. I'm using them to update the value of a form input field. How can I ensure that 'text' is always of type string? This is what I attempted: interface TextInt ...

Open new tab for Angular OAuth2 OIDC login process

Currently, I am incorporating the authorization code flow using angular-oauth2-oidc in my Angular application. It is a fairly straightforward process. However, I would like to have the ability for the login flow to open in a new tab when the login button ...

Calculate the time difference between the stroke of midnight on a specific date and the present moment using JavaScript, node.js, and

Looking for a way to determine if the current moment is less than 3 minutes after midnight of the next date using a JavaScript Date object (e.g. 09.08.2020 15.45). This condition should evaluate to true for times ranging from 09.09.2020 00:00 up until 09.0 ...

The type declaration for the Storage.prototype.setObject method

I'm facing a challenge in creating a d.ts file for the given DOM feature. Storage.prototype.setObject = function(key:string, value:any) { this.setItem(key, JSON.stringify(value)); } Storage.prototype.getObject = function(key:string) { var va ...

Angular rxjs: Wait for another Observable to emit before subscribing

My setup involves having 2 subscriptions - one is related to my ActivatedRoute, and the other is from ngrx Store. ngOnInit() { this.menuItems$ = this.store.select('menuItems'); this.menuItems$.subscribe(data => { this.menuItem ...

What is the method for passing an element in Angular2 Typescript binding?

Is there a way to retrieve the specific HTML dom element passed through a binding in Angular? I'm having trouble figuring it out, so here is the relevant code snippet: donut-chart.html <div class="donut-chart" (donut)="$element"> ...

Determining the response type of a method within a Typescript decorator through inference

I am seeking to extract the response type of a method that I apply a custom decorator to (specifically an old-style TypeScript experimental decorator, not the newer JS decorators). This is necessary in order to utilize the property names within the respons ...

The compilation of the module has encountered an error with the PostCSS loader. There is a SyntaxError at line 2, character 14 indicating an unknown

I am developing an Angular 8 application. Currently, I am incorporating AlertifyJs into my project. In the styles.css file of Angular, I have imported these libraries: @import '../node_modules/alertifyjs/build/alertify.min.js'; @import '. ...

Guide to incorporating eslint with Next.js in a project that already has an eslint configuration

I recently created a new next.js project within my existing Node.js project, which already has an eslint config set up. Here's how the folder structure looks now: ...

Having trouble compiling Typescript code when attempting to apply material-ui withStyles function

I have the following dependencies: "@material-ui/core": "3.5.1", "react": "16.4.0", "typescript": "2.6.1" Currently, I am attempting to recreate the material-ui demo for SimpleListMenu. However, I am encountering one final compile error that is proving ...

I am unable to nest children within the <Provider> tag when using Typescript Redux

https://i.sstatic.net/hFx3h.png I am encountering this error and I am unsure about the root cause. Any help would be greatly appreciated. Below, I have included a snippet of the code along with the package.json: import React from "react"; ...