|
|
@ -30,15 +30,14 @@ class Onionoo { |
|
|
|
|
|
|
|
// Return object containing endpoint methods
|
|
|
|
return this.options.endpoints.reduce((onionoo, endpoint) => { |
|
|
|
onionoo[endpoint] = this.createEndpointMethod(endpoint); |
|
|
|
onionoo[endpoint] = options => this.get(endpoint, options); |
|
|
|
|
|
|
|
return onionoo; |
|
|
|
}, {}); |
|
|
|
} |
|
|
|
|
|
|
|
// Returns a function to make requests to a given endpoint
|
|
|
|
createEndpointMethod(endpoint) { |
|
|
|
return options => { |
|
|
|
get(endpoint, options) { |
|
|
|
// Build query string (don't encode ':' for search filters)
|
|
|
|
const qs = querystring.encode(options).replace(/%3A/g, ':'); |
|
|
|
|
|
|
@ -86,7 +85,6 @@ class Onionoo { |
|
|
|
return response; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
// Returns a promise for a request
|
|
|
|