Code Monkey home page Code Monkey logo

Comments (5)

typicode avatar typicode commented on May 16, 2024

Hi Ingro, always happy to know my projects are appreciated, thanks :)

Not really sure to undersdand your example, because I don't see user in your code. What does generate.js outputs and how do you get /user?

from json-server.

typicode avatar typicode commented on May 16, 2024

Oh I think I'm getting it. When you get /user, the response is the structure you've shown:

{
  "data": [
    {
      "id": 1,
      "name": "John"
    },
// ...

And because user list is in data, you can't get /user/1.

from json-server.

ingro avatar ingro commented on May 16, 2024

Yeah sorry it wasn't clear on the first thought, that was the response I expect from the server. I need the meta data to manage the pagination on the client application, but as you guessed I can't get a specific user structuring the data in this way.

Completely out of scope but, great avatar choice! :)

from json-server.

typicode avatar typicode commented on May 16, 2024

Thanks, good choice for Radiohead :)

Unfortunately, I don't see a way to use that kind of structure with this project. It would mean creating some all new routes.
And POST, DELETE would need to update the meta properties too.

The current approach in JSON Server for pagination, is to use _start, _end query parameters and the X-TOTAL-COUNT header.

Sorry about that.

Maybe you can have a look at dyson or interfake.

Also, I think it wouldn't take too long to create a custom fake server using Express. Actually, if you look at src/router.js you'll see that the code is quite simple.

Hope it will help.

from json-server.

ingro avatar ingro commented on May 16, 2024

Well thanks for your suggestions, I will look at the resources you linked me, I think you can close this issue, keep up the good work! :D

from json-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.