我正在使用这个端点https://api.github.com/user/${githubIdOrLogin}
。现在,它每小时有 60 个 API 调用。我想增加它。怎么做。这是我的 API 调用代码:
export const getGitHubUserData = async (githubIdOrLogin) => {
return fetch(`https://api.github.com/user/${githubIdOrLogin}`, {
headers: { Accept: "application/json" },
}).then((res) => {
if (!res.ok) {
const err = new Error()
err.response = res
if (res.status === 403 && res.headers.get("X-RateLimit-Remaining") === "0") {
const resetsAtMS = Number(`${res.headers.get("X-RateLimit-Reset")}000`)
err.message = `Rate limit exceeded, try again in ${Math.ceil(
(resetsAtMS - Date.now()) / 60000
)}m`
err.code = "github/rate-limit-exceeded"
err.resetsAt = resetsAtMS
} else if (res.status === 404) {
err.message = `Could not find user data for github:${githubIdOrLogin}`
err.code = "github/not-found"
} else {
// add other cases if you want to handle them
err.message = `Unexpected status code: ${res.status}`
err.code = "github/unknown"
}
return Promise.reject(err)
}
return res.json()
})
}
任何人都请帮我解决这个问题。