Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

random generating api for quotes

const link = "https://type.fit/api/quotes";

diceBtn.addEventListener("click",fetchQuote);//changes quote by click

function fetchQuote(){
      fetch(link)
      .then(response => response.json())
      .then(data => {
        const randomQuoteIndex = Math.round(Math.random()*data.length);
        quote.innerHTML = data[randomQuoteIndex].text;
        (data[randomQuoteIndex]);
      });
}
fetchQuote();//starts page with quote immediatly
Comment

get a quote from random api

// get a quote from random api
Comment

PREVIOUS NEXT
Code Example
Javascript :: convert stream to string javascript 
Javascript :: how to check nan in jquery 
Javascript :: javascript convert number to hex 
Javascript :: javascript detect click outside of element 
Javascript :: open a new tab when clicking on a link react 
Javascript :: delayed in js 
Javascript :: js get hh mm ss 
Javascript :: activate es6 module node 
Javascript :: nodejs delete folder recursively 
Javascript :: specify parameter type in javascript vscode 
Javascript :: javascript change class of item 
Javascript :: countTo add commas to number jquery 
Javascript :: active link color different in react js 
Javascript :: remove unused dependencies in React Ask Question 
Javascript :: sanitise string js 
Javascript :: a JavaScript function to multiply a set of numbers 
Javascript :: install tailwind nextjs 
Javascript :: sleep sort 
Javascript :: node pre gyp error 
Javascript :: pdf darkmode 
Javascript :: nextjs create project with tailwind 
Javascript :: window.open javascript auto close 
Javascript :: javascript get last character of string 
Javascript :: javascript merge two lists without duplicates 
Javascript :: validador de telefone javascript 
Javascript :: moment calculate duration 
Javascript :: javascript string first letter lowercase 
Javascript :: blob to file javascript 
Javascript :: upgrade nodejs and npm ubuntu 
Javascript :: run javascript from uri 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =