@maxdome/request
## Simplest usage
Last updated a year ago by fabsrc .
Original npm · Tarball · package.json
$ cnpm install @maxdome/request 
SYNC missed versions from official npm registry.

Usage

Simplest usage

const Request = require('@maxdome/request').Request;

const response = await new Request().get('http://google.de');

Set options for a request by a name

const RequestBuilder = require('@maxdome/request').RequestBuilder;

const requestBuilder = new RequestBuilder().setOptions('google', {
  url: 'http://google.de',
});

const response = await RequestBuilder.request('google').send();

Set options for all requests

const RequestBuilder = require('@maxdome/request').RequestBuilder;

const google = new RequestBuilder({
  url: 'http://google.de',
});

const response = await google.send();

Define and use a class for more complex options

const RequestBuilder = require('@maxdome/request').RequestBuilder;

const google = new RequestBuilder({
  url: 'http://google.de',
});

class SearchOptions {
  constructor(q) {
    this.q = q;
  }

  toRequestOptions() {
    return {
      url: {
        path: '/search',
        query: {
          q: this.q,
        },
      },
    };
  }
}

const response = await google
  .send(new SearchOptions('how to use google search'));

Current Tags

  • 1.3.4                                ...           latest (a year ago)

7 Versions

  • 1.3.4                                ...           a year ago
  • 1.3.3                                ...           2 years ago
  • 1.3.2                                ...           3 years ago
  • 1.3.1                                ...           3 years ago
  • 1.3.0                                ...           3 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (6)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |