skip to Main Content

REST API is used. At work, I’ve recently been asked to give a request endpoint. For example, I have a request api/products/product-search. How to find out what data it returns?

Maybe it’s a stupid question, but still

2

Answers


  1. if you are using axios you can make this:

    axios.get('https://your-url.com/api/products/product-search')
      .then(response => {
        //response.data have a response data :)
        console.log(response.data);
      })
      .catch(error => {
        console.log(error);
      });
    

    I hope it’s usefull

    Login or Signup to reply.
  2. You can use fetch and console log to see what are returns.
    Also, you can use tools for testing APIs, such as Postman, Insomnia, or cURL.

       fetch('https://url.com/api/products/product-search')
      .then(response => response.json())
      .then(data => console.log(data))
      .catch(error => console.error(error));
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search