R
R
raft882018-05-25 00:05:36
JavaScript
raft88, 2018-05-25 00:05:36

How to correct the response for requests to the json server?

Goodnight!
There are two questions about using the json server package.
1) Json server is used as a module. When requesting to receive filtered data by the passed string, there is a limit on the number of elements in response.data, for example, 10. But elements satisfying the search, for example, 70. How to supplement the response with a string with the number of all found elements (necessary for pagination)? Add middleware, which, with such a request, will give the desired answer, it seems like you can do it, but then you need to code the data filtering logic yourself. It's easier - to add a line with a count. How to implement it?
2) On the front, I use create-react-app, now I run json server separately, separately on the front. How to modify the command in package.json so that everything works after npm start. Now it's like this:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }

I start the servernode server.js

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question