I have a URL \"http://localhost:8888/api/rest/abc
\" which will give following json data. I wants to get this data in my UI using Jquery or java script. I\'m trying
You can use native JS so you don't have to rely on external libraries.
(I will use some ES2015 syntax, a.k.a ES6, modern javascript) What is ES2015?
fetch('/api/rest/abc')
.then(response => response.json())
.then(data => {
// Do what you want with your data
});
You can also capture errors if any:
fetch('/api/rest/abc')
.then(response => response.json())
.then(data => {
// Do what you want with your data
})
.catch(err => {
console.error('An error ocurred', err);
});
By default it uses GET
and you don't have to specify headers, but you can do all that if you want. For further reference: Fetch API reference