Showing posts with label Ajax. Show all posts
Showing posts with label Ajax. Show all posts

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.

Wednesday, January 5, 2022

Ajax

 


Ajax is used to load data from the server asynchoronously  without reloading the entire page 
using http get request . Ajax also used to send data using http post request. 

Testing controller

------Controller------------- @RestController @RequestMapping("/items") public class ItemController {     private final ItemServic...