Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@octokit/request

Package Overview
Dependencies
Maintainers
3
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/request - npm Package Compare versions

Comparing version 5.0.3 to 5.1.0

5

package.json
{
"name": "@octokit/request",
"description": "Send parameterized requests to GitHub’s APIs with sensible defaults in browsers and Node",
"version": "5.0.3",
"version": "5.1.0",
"license": "MIT",

@@ -36,2 +36,3 @@ "files": [

"devDependencies": {
"@octokit/auth-app": "^2.1.2",
"@pika/pack": "^0.5.0",

@@ -43,2 +44,3 @@ "@pika/plugin-build-node": "^0.6.0",

"@types/jest": "^24.0.12",
"@types/lolex": "^3.1.1",
"@types/node": "^12.0.3",

@@ -49,2 +51,3 @@ "@types/node-fetch": "^2.3.3",

"jest": "^24.7.1",
"lolex": "^4.2.0",
"prettier": "^1.17.0",

@@ -51,0 +54,0 @@ "semantic-release": "^15.10.5",

47

README.md

@@ -52,2 +52,6 @@ # request.js

👶 [Small bundle size](https://bundlephobia.com/result?p=@octokit/request@5.0.3) (\<4kb minified + gzipped)
😎 [Authenticate](#authentication) with any of [GitHubs Authentication Strategies](https://github.com/octokit/auth.js).
👍 Sensible defaults

@@ -63,4 +67,2 @@

👶 Small bundle size (\<5kb minified + gzipped)
## Usage

@@ -115,2 +117,4 @@

For GraphQL request we recommend using [`@octokit/graphql`](https://github.com/octokit/graphql.js#readme)
```js

@@ -150,2 +154,41 @@ const result = await request("POST /graphql", {

## Authentication
The simplest way to authenticate a request is to set the `Authorization` header directly, e.g. to a [personal access token](https://github.com/settings/tokens/).
```js
const requestWithAuth = request.defaults({
headers: {
authorization: "token 0000000000000000000000000000000000000001"
}
});
const result = await request("GET /user");
```
For more complex authentication strategies such as GitHub Apps or Basic, we recommend the according authentication library exported by [`@octokit/auth`](https://github.com/octokit/auth.js).
```js
const { createAppAuth } = require("@octokit/auth-app");
const auth = createAppAuth({
id: process.env.APP_ID,
privateKey: process.env.PRIVATE_KEY,
installationId: 123
});
const requestWithAuth = request.defaults({
request: {
hook: auth.hook
},
mediaType: {
previews: ["machine-man"]
}
});
const { data: app } = await requestWithAuth("GET /app");
const { data: app } = await requestWithAuth("POST /repos/:owner/:repo/issues", {
owner: "octocat",
repo: "hello-world",
title: "Hello from the engine room"
});
```
## request()

@@ -152,0 +195,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc