Basic fetch example
by Financial Modeling Prep
HTML
<input type="button" id="basicFetchButton" value="Try it">
JavaScript
document.getElementById("basicFetchButton").addEventListener("click", function(){
const options = {
method: "GET",
headers: new Headers({'Authorization': 'test1'}),
mode: 'no-cors'
};
// Loading the jQuery code
fetch("https://fmpcloud.io/api/v3/mutual-fund-holder/AAPL?apikey=demo", options)
.then(function (response) {
console.log(response);
response.text().then(function (responseText) {
console.log(responseText);
alert("Done using Fetch!");
});
});
});