Skip to content

Function: jsonp()

jsonp<T>(url, callbackParam?): Stream<T>

Defined in: streams/jsonp.ts:17

Creates a stream that performs a JSONP request and emits the resulting data once.

This function provides a reactive way to handle JSONP requests, which are often used to bypass the same-origin policy for loading data from a different domain. It dynamically creates a <script> tag, handles the response via a global callback, and then cleans up after itself. The stream emits a single value and then completes.

Type Parameters

T

T = any

The type of the JSONP data to be emitted.

Parameters

url

string

The URL to make the JSONP request to.

callbackParam?

string = 'callback'

The name of the query parameter for the callback function.

Returns

Stream<T>

A new stream that emits the JSONP data and then completes.

Released under the MIT License.