Home Reference Source
import Request from '~/models/Request/Request.js'
public class | source

Request

Constructor Summary

Public Constructor
public

constructor(requestData: Object)

Creates request given path.

Member Summary

Protected Members
protected

Method Summary

Public Methods
public

cancel()

Cancels the request.

public

format(data: Object): Object

Formats the request object and returns an object of Request<T>'s T.

public

async run(o: Object): Promise

Performs the request

Public Constructors

public constructor(requestData: Object) source

Creates request given path. Provide options as object

Params:

NameTypeAttributeDescription
requestData Object

Object describing request. Bare mininmum info is providing path.

requestData.host string
  • nullable: true

If cross origin, provide. Specifying will mean NO CSRF token passed

requestData.path string

Path of request

requestData.auth string

Authorization header

requestData.data any

Any data to send as part of request.

requestData.formData Object

Automatically converted to form data.

requestData.contentType string
  • nullable: true

Content type header

requestData.headers Object
  • nullable: true

Additional request headers.

requestData.method HTTPMethod
  • optional
  • default: get

Method request type

Protected Members

protected _path: string source

Public Methods

public cancel() source

Cancels the request. Does not work with pagination

public format(data: Object): Object source

Formats the request object and returns an object of Request<T>'s T.

Params:

NameTypeAttributeDescription
data Object

Data (JSON?) from the request.

Return:

Object

formatted object.

public async run(o: Object): Promise source

Performs the request

Params:

NameTypeAttributeDescription
o Object
  • optional
  • default: {}

Options

o.format boolean
  • optional
  • default: true

Set to false to not format

Return:

Promise

resolves to format of object. See return type of Request#format