Manage the launch of the mocked api using miragejs library
- Source
Methods
(static) createFakeApi() → {object}
Create a mocked server to mock an api using miragejs libray
- Source
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
- Source
Returns:
Return true
if 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:
Name | Type | Description |
---|---|---|
id | number | The user Id to fetch |
- Source
Returns:
Return true
if the user exists, false
if not.
- Type:
- boolean
Example
const id=12
if (userExists(id)) {
console.log('User exists !')
}