MCPcopy Create free account
hub / github.com/AyushSaini00/60minuteJavaScript / getInfo

Function getInfo

Superhero-Card/app.js:19–49  ·  view source on GitHub ↗
(apiURL)

Source from the content-addressed store, hash-verified

17}
18
19function getInfo(apiURL){
20 fetch(apiURL)
21 .then(response => {
22 if(!response.ok){
23 url(); //re fetch with new apiURL if response wasn't ok
24 throw new Error('Network response was not ok');
25 }
26 return response.json();
27 })
28 .then(data => {
29 nameEl.innerText = data.name;
30
31 imgEl.src = data.images.sm;
32 imgEl.setAttribute('alt', data.name);
33
34 fullNameEl.innerText = data.biography.fullName;
35
36 publisherEl.innerText = data.biography.publisher;
37
38 intelligenceEl.innerText = data.powerstats.intelligence;
39 strengthEl.innerText = data.powerstats.strength;
40 speedEl.innerText = data.powerstats.speed;
41 durabilityEl.innerText = data.powerstats.durability;
42 powerEl.innerText = data.powerstats.power;
43 combatEl.innerText = data.powerstats.combat;
44 })
45 .catch(error => {
46 console.log('problem : ', error);
47
48 });
49}
50
51window.addEventListener('load', url);

Callers 1

urlFunction · 0.85

Calls 1

urlFunction · 0.85

Tested by

no test coverage detected