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

Commit 13c116f

Browse files
committed
Add micro-api-client pagination
This still requires the pagination parameters to be added to open-api. This is also a breaking change, unfortunately.
1 parent 64c68b5 commit 13c116f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/open-api/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const http = require('http')
55
const fetch = require('node-fetch').default || require('node-fetch') // Webpack will sometimes export default exports in different places
66
const Headers = require('node-fetch').Headers
77
const camelCase = require('lodash.camelcase')
8-
const { JSONHTTPError, TextHTTPError } = require('micro-api-client')
8+
const { JSONHTTPError, TextHTTPError, getPagination } = require('micro-api-client')
99
const debug = require('debug')('netlify:open-api')
1010
const { existy, sleep, unixNow } = require('./util')
1111
const isStream = require('is-stream')
@@ -87,8 +87,6 @@ exports.generateMethod = method => {
8787
opts.method = method.verb.toUpperCase()
8888
debug(`method: ${opts.method}`)
8989

90-
// TODO: Consider using micro-api-client when it supports node-fetch
91-
9290
async function makeRequest() {
9391
let response
9492
try {
@@ -161,10 +159,8 @@ exports.generateMethod = method => {
161159
if (!response.ok) {
162160
throw new JSONHTTPError(response, json)
163161
}
164-
// TODO: Support pagination
165-
// const pagination = getPagination(response)
166-
// return pagination ? { pagination, items: json } : json
167-
return json
162+
const pagination = getPagination(response)
163+
return pagination ? { pagination, items: json } : json
168164
}
169165

170166
debug('parsing text')

0 commit comments

Comments
 (0)