GET complex in Node.js API

Asked

Viewed 46 times

1

Following good practices, what would be the most appropriate way to perform a complex GET to retrieve the products according to their properties?

Imagine we have the methods for the Product Business Model. Tabela de métodos

  1. Using query string in GET would not conflict with GET that returns a specific product?
  2. Creating a specific end point as /product?

Could you please demonstrate with examples?

  • 1

    Actually, the query string would not conflict because it would look something like: /produtos?queryString, right?

  • Describing the general problem you will get only a general answer. Example: "How to build a house?" , "Use blocks and cement, build solid walls". Instead ask something specific and responsive in a useful way: "How to lift a wall using this type of block with such a slope and such height safely?" , answer: "Position the blocks in such format, run this block placement algorithm, do not use this tool because there is such a risk, here is an example running from a wall ready for you to see how it does [link]". See? Too many wide questions don’t help.

  • I understood his point of view and agree with him, but what I’m looking for is this, I don’t want a concrete answer, so I described a broad scenario. What I’m looking for is an answer that gives me ideas and through them I can go after the best solution to my problem. I appreciate your feedback.

  • Has any response helped solve the problem and can address similar questions from other users? If so, make sure to mark the answer as accepted. To do this just click on the left side of it (below the indicator of up and down votes).

1 answer

2


You can do with query even, its route will only be identified as GET of a specific product if you send information after the bar. As is not the case will enter the first GET that brings all products. On this route you must put the logic of the search according to the parameters sent.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.