基于 Fetch API 的 GitHub GraphQL 数据请求方法

使用 Fetch API 发送 GitHub GraphQL 请求

fetch-github-graphql 模块提供了一种便捷的方式,可以使用 Fetch API 向 GitHub GraphQL 发送请求。

安装

使用 npm 或 yarn 安装 fetch-github-graphql 模块:

npm install fetch-github-graphql --save

# 或

yarn add fetch-github-graphql

使用方法

const gh = require('fetch-github-graphql');

const token = 'YOUR_GITHUB_PERSONAL_ACCESS_TOKEN';

const query = `
  query {
    # Your GraphQL query here
  }
`;

const variables = {
  # Your query variables here
};

gh(token, query, { variables })
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });

License

MIT

zip
Fetch-GitHub-Graphql-master.zip 预估大小:7个文件
folder
Fetch-GitHub-Graphql-master 文件夹
file
LICENSE 1KB
file
cubohub.yml 321B
file
README.md 540B
file
renovate.json 242B
file
.gitignore 914B
file
index.js 704B
file
package.json 649B
zip 文件大小:3.79KB