http-client-debug

debug utils for http-client

MIT License

Downloads
8
Stars
4
Committers
2

http-client-debug

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