Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

randome words api

// GetRandom Words from API and push to Array
async function getRandomWord() {

  const res = await fetch('https://random-words-api.vercel.app/word');

  const data = await res.json();
  return data[Object.keys(data)[0]].word.toLowerCase();

}

getRandomWord();

// Add Word to DOM
async function addWordToDOM() {
  randomWord = await getRandomWord();
  word.innerHTML = randomWord;
}
 
PREVIOUS NEXT
Tagged: #randome #words #api
ADD COMMENT
Topic
Name
2+4 =