0.1.4 • Published 6 years ago

intercept-response v0.1.4

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

intercept-response

Collects writes to Node.js http.ServerResponse and resolves to node-fetch Response

interceptResponse(res)

const { interceptResponse } = require('intercept-response');

const http = require('http');

http.createSever((req, res) => {
  interceptResponse(res)
    .then(fetchResponse => fetchResponse.text())
    .then(text => assert(text === 'response body'));
    
  res.writeHead(200);  
  res.end('response body');
});