use-jsonp
A custom React hook for making JSONP requests.
Installation
Install with npm:
$ npm install --save use-jsonp
(or yarn):
$ yarn add use-jsonp
Example
Make a request to a server that supports jsonp.
;; const MailchimpForm = { type MailchimpResponse = msg: string result: "success" | "error" const sendJsonP = useJSONP<MailchimpResponse> url: 'https://somemailchimpaccount.us12.list-manage.com/subscribe/post-json?u=###&FNAME=bobby&EMAIL=bobby@somedomain.com' id: 'mailchimpScript, callback: data => console.log(data), callbackParam: "c", }) return ( <form onSubmit={() => sendJsonP()}>...</form> )}