Skip to content

Refactor fetchr API #275

Open
Open
@redonkulus

Description

@redonkulus

@snyamathi @lingyan @pablopalacios

Goal

Make the API more intuitive and easy to use for developers

Background

Some of this work is based on the discussion in #263 (comment)

Proposals

Simplify CRUD signatures

  • Remove method chaining and just pass an options object with everything that is needed inside. It would be easy to mock and would make it clear which options are being passed (and wouldn't require unnecessary typing as the end call or the double null).
  • Remove callback interface
  • Remove end() method

Current:

fetchr.read('resource', params, { timeout: 500 });
fetchr.create('resource', params, body, { timeout: 500 });

Proposal:

fetchr.read({
  resource: 'foo',
  params: Object,

  // additional options
  cors?: Boolean,
  constructGetUri?: Function
  retry?: Object,
  timeout?: Number
  unsafeAllowRetry?: Boolean,
});

fetchr.create({
  resource: 'foo',
  params: Object,
  body: Object,
  
  // additional options
  cors?: Boolean,
  constructGetUri?: Function
  retry?: Object,
  timeout?: Number
  unsafeAllowRetry?: Boolean,
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions