Public
Edited
Oct 1, 2023
Importers
1 star
Insert cell
Insert cell
Insert cell
username = ''
Insert cell
accessToken = ''
Insert cell
domain = 'https://gitlab.com'
Insert cell
async function fetchFromGitLabRaw(url) {
url = url.startsWith('/')
? `${domain}/api/v4${url}`
: url
const response = await fetch(url, {mode: 'cors', headers: {'Authorization': `Bearer ${accessToken}`}})

return response
}
Insert cell
async function fetchFromGitLab(url) {
const response = await fetchFromGitLabRaw(url)

return await response.json()
}
Insert cell
async function fetchAllPagesFromGitLab(url) {
const results = []
let page = 0
while(url) {
const response = await fetchFromGitLabRaw(url)
const data = await response.json()

results.push(...data)

url = parseLinkHeader(response.headers.get('Link'))?.next?.url
}

return results
}
Insert cell
parseLinkHeader = require('https://bundle.run/parse-link-header@2.0.0')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more