-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
Currently, the recommended way to use api-wrapper is to initialize a new instance each time you use it, as there is some left over state pollution which can cause unwanted side effects.
Take for example the following:
const api = new DadiAPI(config)
// Query for metadata
api
.in('collection')
.find({ extractMetadata: true })
.then(result => {})
.catch(err => {})
// Create a new object
api
.in('collection')
.create({ example: true })
.then(result => {})
.catch(err => {})
The second query above, creating a new object, will fail, as the extractMetadata option will still be present and cause api-wrapper to post the request to /1.0/example/collection/count rather than /1.0/example/collection.
eduardoboucas