1

I'm currently dealing with API rate:

API rate limit exceeded. 
(But here's the good news: 
Authenticated requests get a higher rate limit. Check out the documentation for more details.)

I've tried multiple different methods, but seems like I'm missing something, here is my current state:

const TOKEN = process.env.GITHUB_TOKEN;

  try {
    return await fetch(
      url +
        new URLSearchParams({
          method: "GET",
          headers: {
            Authorization: `Bearer ${TOKEN}`,
          },
        })
    ).then((res) => res.json());
  } catch (err) {
    console.log("Error at Get Pulls", err);
  }

I've tried with Bearer, without, with lowercase, but at the end I always get the same error.

1 Answer 1

2

You are passing the headers and method inside the URLSearchParams, which is wrong. You must pass these properties to the fetch method.

URLSearchParams is a helper to work with the query string of a URL.

So do this instead

await fetch(url, {
    method: "GET",
    headers: {
        Authorization: `Bearer ${TOKEN}`,
    },
}).then((res) => res.json());
Sign up to request clarification or add additional context in comments.

1 Comment

paste your updated code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.