Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 1.2 KB

README.md

File metadata and controls

44 lines (30 loc) · 1.2 KB

@pbe/fastify-jsonp

checks js-standard-style npm npm bundle size

A plugin for Fastify that adds support for jsonp response.

Installation

npm i @pbe/fastify-jsonp

or

yarn add @pbe/fastify-jsonp

Example

const fastify = require('fastify')()

fastify.register(require('@pbe/fastify-jsonp'))

fastify.get('/', (req, reply) => {
  reply.jsonp({ hello: 'world' });
});

fastify.listen({ port: 3000 });

Terminal:

$ curl "http://localhost:3000/?callback=myCallback"
$ /**/ typeof myCallback === 'function' && myCallback({"hello":"world"});

License

MIT License