mirror of
https://github.com/SethCohen/github-releases-to-discord
synced 2026-09-14 20:13:23 +00:00
chore: added updated dependencies
This commit is contained in:
+30
-9
@@ -12,11 +12,11 @@
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
Load <code>@octokit/request-error</code> directly from <a href="https://cdn.skypack.dev">cdn.skypack.dev</a>
|
||||
Load <code>@octokit/request-error</code> directly from <a href="https://esm.sh">esm.sh</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { RequestError } from "https://cdn.skypack.dev/@octokit/request-error";
|
||||
import { RequestError } from "https://esm.sh/@octokit/request-error";
|
||||
</script>
|
||||
```
|
||||
|
||||
@@ -38,9 +38,6 @@ const { RequestError } = require("@octokit/request-error");
|
||||
|
||||
```js
|
||||
const error = new RequestError("Oops", 500, {
|
||||
headers: {
|
||||
"x-github-request-id": "1:2:3:4",
|
||||
}, // response headers
|
||||
request: {
|
||||
method: "POST",
|
||||
url: "https://api.github.com/foo",
|
||||
@@ -51,17 +48,41 @@ const error = new RequestError("Oops", 500, {
|
||||
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; // POST
|
||||
error.request.url; // https://api.github.com/foo
|
||||
error.request.body; // { bar: 'baz' }
|
||||
error.request.headers; // { authorization: 'token [REDACTED]' }
|
||||
error.request; // { method, url, headers, body }
|
||||
error.response; // { url, status, headers, data }
|
||||
```
|
||||
|
||||
### Usage with Octokit
|
||||
|
||||
```js
|
||||
try {
|
||||
// your code here that sends at least one Octokit request
|
||||
await octokit.request("GET /");
|
||||
} catch (error) {
|
||||
// Octokit errors always have a `error.status` property which is the http response code
|
||||
if (error.status) {
|
||||
// handle Octokit error
|
||||
} else {
|
||||
// handle all other errors
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
Reference in New Issue
Block a user