subtext

HTTP payload parser.

Latest Version: 7.0.3
hapi-family
Installation:

npm: npm install @hapi/subtext

yarn: yarn add @hapi/subtext

Module Status:
Version License Node Dependencies Travis End of Life
7.0.3
hapi helmet github logo
BSD 12 Dependency Status Build Status
6.1.3
hapi helmet github logo
BSD 12, 10, 8 Dependency Status Build Status
5.1.2
hapi helmet github logo
Commercial 10, 8, 6 Dependency Status Build Status

Introduction

subtext parses the request body and returns it in a promise.

Example

const Http = require('http');
const Subtext = require('@hapi/subtext');

Http.createServer(async (request, response) => {

  const { payload, mime } = await Subtext.parse(request, null, { parse: true, output: 'data' });

  response.writeHead(200, { 'Content-Type': 'text/plain' });
  response.end(`Payload contains: ${JSON.stringify(payload)}`);

}).listen(1337, '127.0.0.1');

console.log('Server running at http://127.0.0.1:1337/');