Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to display api data in html

const p = document.getElementById("myPelement")
fetch('http://example.com/movies.json')
    .then((response) => {
        return response.json();
    })
    .then((data) => {
        p.innerText = data
    });
Comment

how to view api data in html

fetch("https://www.thecocktaildb.com/api/json/v1/1/random.php")
  .then((response) => {
    if (response.ok) {
      return response.json();
    } else {
      throw new Error("NETWORK RESPONSE ERROR");
    }
  })
  .then(data => {
    console.log(data);
    displayCocktail(data)
  })
  .catch((error) => console.error("FETCH ERROR:", error));
Code language: JavaScript (javascript)
Comment

PREVIOUS NEXT
Code Example
Javascript :: find whitespace in string js 
Javascript :: jquery add remove class timer 
Javascript :: dockerfile copy ignore node_modules 
Javascript :: package.json set environment variables 
Javascript :: react not getting img by src 
Javascript :: node js server get images from folder 
Javascript :: node red admin password setting 
Javascript :: today date javascript 
Javascript :: javascript get image width and height 
Javascript :: Prevent Double Submit with JavaScript 
Javascript :: get element class javascript 
Javascript :: laravel array to js 
Javascript :: create react app cmd 
Javascript :: owl carousel get started 
Javascript :: vscode react auto import 
Javascript :: how to get the integer part of a string in javascript 
Javascript :: chart.js chart is not defined 
Javascript :: nl2br javascript 
Javascript :: moment check greater than current time 
Javascript :: checkvalidity 
Javascript :: ngmodel angular 
Javascript :: nodejs check if string matches regex 
Javascript :: word to char array javascript 
Javascript :: upload multiple images cloudinary 
Javascript :: jsx render array 
Javascript :: calculate today date javascript 
Javascript :: nodejs https server 
Javascript :: cypress get element val and return it 
Javascript :: faker.js avatar 
Javascript :: get number of days between two dates mongodb query 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =