mswjs / data

Data modeling and relation library for testing JavaScript applications.

Home Page:https://npm.im/@mswjs/data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Delay for toHandlers

mwyrembl opened this issue · comments

This is a feature request.

It would be helpful for local development and testing if the toHandlers method would support a delay parameter in milliseconds to delay the response.

Example for delaying the response for 2 seconds:

toHandlers("rest", "http://localhost:3000/api/", 2000);

Maybe consider adding response transformers(https://mswjs.io/docs/basics/response-transformer)

I believe I've answered this in this discussion.

My use case is that the response format of the actual network request is

{
  success: true,
  data: user,        // model
  message: "success"
}

In that case, toHandlers doesn't fit in.