@pbe/fastify-jsonp
v1.0.2
Published
A Fastify plugin to add jsonp support
Downloads
5
Maintainers
Readme
@pbe/fastify-jsonp
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"});