github-pages-deploy-action/node_modules/@octokit/request-error/README.md

68 lines
1.5 KiB
Markdown
Raw Normal View History

2020-01-28 13:07:56 +08:00
# http-error.js
> Error class for Octokit request errors
[![@latest](https://img.shields.io/npm/v/@octokit/request-error.svg)](https://www.npmjs.com/package/@octokit/request-error)
2020-07-05 03:43:39 +08:00
[![Build Status](https://github.com/octokit/request-error.js/workflows/Test/badge.svg)](https://github.com/octokit/request-error.js/actions?query=workflow%3ATest)
2020-01-28 13:07:56 +08:00
## Usage
<table>
<tbody valign=top align=left>
<tr><th>
Browsers
</th><td width=100%>
Load <code>@octokit/request-error</code> directly from <a href="https://cdn.pika.dev">cdn.pika.dev</a>
```html
<script type="module">
import { RequestError } from "https://cdn.pika.dev/@octokit/request-error";
</script>
```
</td></tr>
<tr><th>
Node
</th><td>
Install with <code>npm install @octokit/request-error</code>
```js
const { RequestError } = require("@octokit/request-error");
// or: import { RequestError } from "@octokit/request-error";
```
</td></tr>
</tbody>
</table>
```js
const error = new RequestError("Oops", 500, {
headers: {
2020-07-05 03:43:39 +08:00
"x-github-request-id": "1:2:3:4",
2020-01-28 13:07:56 +08:00
}, // response headers
request: {
method: "POST",
url: "https://api.github.com/foo",
body: {
2020-07-05 03:43:39 +08:00
bar: "baz",
2020-01-28 13:07:56 +08:00
},
headers: {
2020-07-05 03:43:39 +08:00
authorization: "token secret123",
},
},
2020-01-28 13:07:56 +08:00
});
error.message; // Oops
error.status; // 500
error.headers; // { 'x-github-request-id': '1:2:3:4' }
error.request.method; // POST
error.request.url; // https://api.github.com/foo
error.request.body; // { bar: 'baz' }
error.request.headers; // { authorization: 'token [REDACTED]' }
```
## LICENSE
[MIT](LICENSE)