MockedAPI

Manage the launch of the mocked api using miragejs library

Methods

(static) createFakeApi() → {object}

Create a mocked server to mock an api using miragejs libray

Returns:

Returns an object data containing the mocked data

Type: 
object
Example
createFakeApi()

(static) error404() → {boolean}

Sends a fake 404 error from the mocked API

Returns:

Return trueif the user exists, false if not.

Type: 
boolean
Example
return error404()

(static) userExists(id) → {boolean}

Check if the user exists before calling the mocked API

Parameters:
NameTypeDescription
idnumber

The user Id to fetch

Returns:

Return trueif the user exists, false if not.

Type: 
boolean
Example
const id=12
if (userExists(id)) {
 console.log('User exists !')
}