Home Identifier Source Repository

Function

Static Public Summary
public

ajax(settings: Object): Observable

Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.

Static Public

public ajax(settings: Object): Observable source

import ajax from 'json-api-store/src/ajax.js'

Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.

Params:

NameTypeAttributeDescription
settings Object

Can be one of the following:

A string of the URL to make the Ajax call. An object with the following properties

  • url: URL of the request
  • body: The body of the request
  • method: Method of the request, such as GET, POST, PUT, PATCH, DELETE
  • async: Whether the request is async
  • headers: Optional headers
  • crossDomain: true if a cross domain request, else false
  • responseType: "text" (default), "json" or "auto"

Return:

Observable

An observable sequence containing the XMLHttpRequest.

Example:

  source = ajax('/products');
  source = ajax({ url: 'products', method: 'GET' });