Home Reference Source
import Client from 'mockaroo/src/client.js'
public class | source

Client

A client for generating data using mockaroo.

Constructor Summary

Public Constructor
public

constructor(options: Object)

Creates a new instance

Method Summary

Private Methods
private

convertError(response: *): *

Converts error messages from the mockaroo server to error classes

private

getUrl(options: *): String

Generates the rest api url

private

Validates that all required options have be specified.

private

validateFields(fields: Object[])

Public Constructors

public constructor(options: Object) source

Creates a new instance

Params:

NameTypeAttributeDescription
options Object
options.apiKey string

Your mockaroo api key. See http://mockaroo.com/api/docs under "Gaining Access".

options.host string
  • optional
  • default: 'mockaroo.com'

The hostname of the mockaroo server.

options.port int
  • optional
  • default: 80

The port to use.

options.secure boolean
  • optional
  • default: true

Set to false to use http instead of https

Private Methods

private convertError(response: *): * source

Converts error messages from the mockaroo server to error classes

Params:

NameTypeAttributeDescription
response *

Return:

*

private getUrl(options: *): String source

Generates the rest api url

Params:

NameTypeAttributeDescription
options *

Return:

String

private validate() source

Validates that all required options have be specified.

private validateFields(fields: Object[]) source

Params:

NameTypeAttributeDescription
fields Object[]