ExamplesREST API

REST API Mocking

Complete example of mocking a RESTful API with all CRUD operations.

For complete examples with detailed code, see the REST API Mocking section in MASTER_DOCUMENTATION.md.


HTTP Methods

// GET - Retrieve
handler({ method: 'GET', path: '/users' })
 
// POST - Create
handler({ method: 'POST', path: '/users', body: {...} })
 
// PUT - Full replace
handler({ method: 'PUT', path: '/users/1', body: {...} })
 
// PATCH - Partial update
handler({ method: 'PATCH', path: '/users/1', body: {...} })
 
// DELETE - Remove
handler({ method: 'DELETE', path: '/users/1' })

Status Codes

  • 200 - OK
  • 201 - Created
  • 204 - No Content
  • 400 - Bad Request
  • 403 - Forbidden
  • 404 - Not Found
  • 500 - Internal Server Error

Full Documentation

See MASTER_DOCUMENTATION.md for complete REST API examples.