Skip to main content

Example 2: Storing data using HTTP Method

Kvery enables the incorporation of HTTP methods directly in the code. As an example, you can use the GET method to retrieve data from a specified URL and store it in an internal table. Here's a snippet of code that fetches and stores sample data from a URL using the get method:

:var = get('https://dummyjson.com/products/1');

Pretty easy right?

Next, we'll output the data held in our variable. Remember, we're employing a JSON view extension here, ensuring that the data is presented in an easily understandable format.

return(:var);

The result is the retrieved data.

Name
tip

Often, we might not need every piece of data from the JSON file, so we have the option to return specific data elements instead. For instance, if we only want to extract the 'title' from the JSON:

return(:var[title]);
Name

This method allows for more targeted data retrieval, enhancing the efficiency and specificity of our code.