UNPKG

x-http-client

Version:

An http client to make it easier to send requests (including JSONP requests) to the server.

15 lines (13 loc) 500 B
/** * The function to handle `options.cors` setting when sending JSONP requests. If `options.cors` is `true`, the * `crossorigin` attribute of the `script` element we using is set to `use-credentials`. * * @param {HTMLScriptElement} script The script element. * @param {RequestOptions} options The request options. */ function handleScriptCors(script, options) { if (options.cors) { script.setAttribute('crossorigin', 'use-credentials'); } } module.exports = handleScriptCors;