Tuesday, January 11, 2022

fetch() web API to load data from server

 fetch

    ('https://crossorigin.me/https://www.metaweather.com/api/location/2487956/')

    .then(result => {

        console.log(result);

        return result.json(); //fetch () will return a promise and converting to json object

    })

     .then(data=>console.log(data))

    .catch(error => {

        console.log(error);

    });

here https://crossorigin.me is used to prevent same origin policy.

No comments:

Post a Comment

Element of a good table (Ref: Database design mere mortals by Michael J. Hernandez)

  Elements of the Ideal Table: It represents a single subject, which can be an object or event that reduces the risk of potential data integ...