0.1.2 • Published 8 years ago

http-client-debug v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

http-client-debug

NPM version Build Status Test coverage Dependency Status

debug utils for http-client

Install

$ npm install http-client-debug

Usage

import { createStack } from 'http-client';

const middlewares = [
  header('X-Auth-Key', key),
  header('X-Auth-Email', email),
  base('https://api.cloudflare.com/client/v4'),
  parseJSON(),
];

if (process.env.NODE_ENV === 'development') {
  const { log } = require('http-client-debug');
  middlewares.push(log());
}

const stack = createStack(...middlewares);

// Get "response": ....

or use a path to log property from response:

import { createStack } from 'http-client';

const middlewares = [
  header('X-Auth-Key', key),
  header('X-Auth-Email', email),
  base('https://api.cloudflare.com/client/v4'),
  parseJSON(),
];

if (process.env.NODE_ENV === 'development') {
  const { log } = require('http-client-debug');
  middlewares.push(log('jsonData.user.name'));
}

const stack = createStack(...middlewares);

// Get "response.jsonData.user.name": Peter

API

log(path)

path

Optional Type: string

info(path)

path

Optional Type: string

warn(path)

path

Optional Type: string

error(path)

path

Optional Type: string

License

MIT © C.T. Lin