fetch('http://localhost:5001/api/title/topposter') .then(function (response) { return response.json(); }) .then(function (data) { names(data) }) .then(data => obj = data); code example
Example 1: fetch api javascript
fetch('https://apiYouWantToFetch.com/players') // returns a promise
.then(response => response.json()) // converting promise to JSON
.then(players => console.log(players)) // console.log to view the response
Example 2: fetch suntax
fetch('http://example.com/movies.json')
.then((response) => {
return response.json();
})
.then((data) => {
console.log(data);
});