surfmuggle / Cubert

To become a jedi one must start as a novice
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

HTML consume and send data to a webservice #29

Open surfmuggle opened 3 years ago

surfmuggle commented 3 years ago

There are website that offer public web services

  1. https://www.predic8.de/public-soap-web-services.htm for example fruit shop api
  2. https://codepunk.io/sending-a-collection-of-entity-items-to-a-web-api-web-service/ <--???

Fruit shop api

  1. Load all products and render a link for every fruit
  2. If user clicks on or moves the mouse over a link show the details for this fruit: name, image, price
surfmuggle commented 3 years ago

added hint about fruit shop api and new label

surfmuggle commented 3 years ago

To call a webservice from the browser fetch can be used.

function loadData()
{
    const productURL = "https://api.predic8.de/shop/products/";
    fetch(productURL)
            .then(response => response.json())
            .then(data => listProducts(data));
}

function listProducts(data)
{
    console.log(data.products);
    data.products.forEach(product => {
        console.log(product.name);  
    });
}
surfmuggle commented 3 years ago

I am having trouble posting / adding a new product . Therefore i recommend that you start with listing the products (see attached screen). Fruit_Api_Demo

surfmuggle commented 3 years ago