Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Add micro-api-client pagination #44

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/open-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const http = require('http')
const fetch = require('node-fetch').default || require('node-fetch') // Webpack will sometimes export default exports in different places
const Headers = require('node-fetch').Headers
const camelCase = require('lodash.camelcase')
const { JSONHTTPError, TextHTTPError } = require('micro-api-client')
const { JSONHTTPError, TextHTTPError, getPagination } = require('micro-api-client')
const debug = require('debug')('netlify:open-api')
const { existy, sleep, unixNow } = require('./util')
const isStream = require('is-stream')
Expand Down Expand Up @@ -87,8 +87,6 @@ exports.generateMethod = method => {
opts.method = method.verb.toUpperCase()
debug(`method: ${opts.method}`)

// TODO: Consider using micro-api-client when it supports node-fetch

async function makeRequest() {
let response
try {
Expand Down Expand Up @@ -161,9 +159,8 @@ exports.generateMethod = method => {
if (!response.ok) {
throw new JSONHTTPError(response, json)
}
// TODO: Support pagination
// const pagination = getPagination(response)
// return pagination ? { pagination, items: json } : json
const pagination = getPagination(response)
if (existy(pagination)) json.pagination = pagination
return json
}

Expand Down