1.0.3 • Published 6 years ago

mof-json v1.0.3

Weekly downloads
2
License
ISC
Repository
-
Last release
6 years ago

mof-json

mof-json is a middleware of floodesh, it automatically parses response to JSON as long as one of below conditions is met: 1. Content-Type is kind of 'json' 2. Current url matches the provided RegExp p

Install

npm install mof-json

Usage

const json = require('mof-json');
const request = require('mof-request');
const Worker = require("floodesh/worker");

const worker = new Worker();

worker.use(co.wrap(request(worker.config.downloader))); // make sure the ctx existing before using json

// default parse only Content-Type is json
worker.use(json());

// parse when Content-Type is json or url matches pattern
const options = {p: /\/path\/to\/page/};
worker.use(json(options));

Test

npm test
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago