Reference
@muze-nl/metro-api reference
api(base, methods)
Creates an API instance. base may be a Metro client or any option accepted by metro-core’s client(). methods is an object whose functions are bound to the API instance, so use normal function syntax rather than arrow functions when you need this.get(), this.post(), and friends.
API adds thrower() and getdata() middleware. Non-OK responses throw, and OK responses with response.data return that data directly.
jsonApi(base, methods)
Creates a JsonAPI. It adds JSON middleware before the normal API behaviour: object request bodies are encoded as JSON, JSON responses are parsed into response.data, non-OK responses throw, and API methods return parsed data where available.
Nested API sections
Plain nested objects become nested API sections. Methods are still bound to the root API by default, so this.get() remains available.
api.extend(methods)
Returns a new API instance with the additional methods.