Skip to content

仓库

查询仓库。

const TOKEN = '123456';

const url = `https://api.github.com/user/repos`;
const options = { method: 'GET', headers: { Authorization: 'Bearer ' + TOKEN } };

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

查询单仓库信息。

const TOKEN = '123456';
const NAME = 'yourname';
const REPO = 'mygit';

const url = `https://api.github.com/repos/${NAME}/${REPO}`;
const options = { method: 'GET', headers: { Authorization: 'Bearer ' + TOKEN } };

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

联系 math@baima.site