wishthis/node_modules/@octokit/request-error
2023-02-08 13:35:10 +01:00
..
dist-node Update dependencies 2023-02-08 13:35:10 +01:00
dist-src Update dependencies 2022-06-08 12:36:39 +02:00
dist-types Update dependencies 2023-02-08 13:35:10 +01:00
dist-web Update dependencies 2022-06-08 12:36:39 +02:00
LICENSE Add production dependencies 2022-01-21 09:28:41 +01:00
package.json Update dependencies 2023-02-08 13:35:10 +01:00
README.md Update dependencies 2022-11-30 13:56:09 +01:00

http-error.js

Error class for Octokit request errors

@latest Build Status

Usage

Browsers Load @octokit/request-error directly from cdn.skypack.dev
<script type="module">
import { RequestError } from "https://cdn.skypack.dev/@octokit/request-error";
</script>
Node

Install with npm install @octokit/request-error

const { RequestError } = require("@octokit/request-error");
// or: import { RequestError } from "@octokit/request-error";
const error = new RequestError("Oops", 500, {
  request: {
    method: "POST",
    url: "https://api.github.com/foo",
    body: {
      bar: "baz",
    },
    headers: {
      authorization: "token secret123",
    },
  },
  response: {
    status: 500,
    url: "https://api.github.com/foo",
    headers: {
      "x-github-request-id": "1:2:3:4",
    },
    data: {
      foo: "bar",
    },
  },
});

error.message; // Oops
error.status; // 500
error.request; // { method, url, headers, body }
error.response; // { url, status, headers, data }

LICENSE

MIT