Skip to content

Clear state after terminator methods are called #57

Description

@adamkdean

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions