Giter Site home page Giter Site logo

simobain / luminator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tictactrip/luminator

1.0 1.0 0.0 210 KB

๐Ÿ•ธ Axios Luminati agent.

Home Page: https://www.tictactrip.eu

License: GNU General Public License v3.0

JavaScript 3.48% TypeScript 96.52%

luminator's Introduction

luminator

Dependencies Coverage Build Status License PRs Welcome

Description

This repository provides an Axios Luminati agent.

Install

yarn add @tictactrip/luminator

How to use it?

Make a get request

import { Luminator } from "@tictactrip/luminator";

const agent = new Luminator(username, password, config);

const response = await agent.fetch({ method: 'get', url: 'https://api.domain.com/examples' });

Make a post request:

import { Luminator } from "@tictactrip/luminator";

const agent = new Luminator(username, password, config);

const response = agent.fetch({
    method: 'post',
    url: '/user',
    data: {
      firstName: 'Fred',
      lastName: 'Flintstone'
    }
  });

Config object:

{
  url: '/examples',
  method: 'get', // default
  baseURL: 'https://api.domain.com/api/',
  transformRequest: [function (data, headers) {
    return data;
  }],
  transformResponse: [function (data) {
    return data;
  }],
  // `headers` are custom headers to be sent
  headers: {'X-Requested-With': 'XMLHttpRequest'},
  params: {
    ID: 12345
  },
  paramsSerializer: function (params) {
    return Qs.stringify(params, {arrayFormat: 'brackets'})
  },
  data: {
    firstName: 'Fred'
  },
  timeout: 1000,
  withCredentials: false, // default
  adapter: function (config) {
    /* ... */
  },
  auth: {
    username: 'admin',
    password: 'password'
  },
  responseType: 'json', // default
  responseEncoding: 'utf8', // default
  xsrfCookieName: 'XSRF-TOKEN', // default
  xsrfHeaderName: 'X-XSRF-TOKEN', // default
  onUploadProgress: function (progressEvent) {
    // Do whatever you want with the native progress event
  },
  onDownloadProgress: function (progressEvent) {
    // Do whatever you want with the native progress event
  },
  maxContentLength: 2000,
  validateStatus: function (status) {
    return status >= 200 && status < 300; // default
  },
  maxRedirects: 5, 
  socketPath: null, 
  cancelToken: new CancelToken(function (cancel) {
  })
}

Response object:

{
  // `data` is the response that was provided by the server
  data: {},

  // `status` is the HTTP status code from the server response
  status: 200,

  // `statusText` is the HTTP status message from the server response
  statusText: 'OK',

  // `headers` the headers that the server responded with
  // All header names are lower cased
  headers: {},

  // `config` is the config that was provided to `axios` for the request
  config: {},

  // `request` is the request that generated this response
  // It is the last ClientRequest instance in node.js (in redirects)
  // and an XMLHttpRequest instance the browser
  request: {}
}

Scripts

Run using yarn run <script> command.

clean       - Remove temporarily folders.
build       - Compile source files.
build:watch - Interactive watch mode, compile sources on change.
lint        - Lint source files.
lint:fix    - Fix lint source files.
test        - Runs all tests with coverage.
test:watch  - Interactive watch mode, runs tests on change.

License

GPL-3.0 ยฉ Tictactrip

luminator's People

Contributors

rimiti avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.