Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

fetch json file

fetch('./server.json')
	.then(response => response.json())
	.then(data => console.log(data))
	.catch(err => console.error(err));
Comment

read json file with fetch

const todoUrl ='https://jsonplaceholder.typicode.com/todos';
  
function getAllTodos(){
        return new Promise((resolve => {
            fetch(new Request(todoUrl)).
            then( res => {
                return res.json();
            })
            .then(data => {resolve(data);
            });
        }))
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord.js v13 
Javascript :: get timezone javascript 
Javascript :: js check if number has decimals 
Javascript :: https with express 
Javascript :: jquery change selected option 
Javascript :: javascript redirect to relative url 
Javascript :: javascript redirect browser 
Javascript :: javascript redirect new window 
Javascript :: convert moment date to utc format moment 
Javascript :: change form action js 
Javascript :: get class count in jquery 
Javascript :: javascript parentnode 
Javascript :: how to check if a tag has any chidren 
Javascript :: console redux state shows proxy 
Javascript :: classlist remove all classes 
Javascript :: express js cors 
Javascript :: open popup after 10 seconds javascript 
Javascript :: how to write img jsx 
Javascript :: angular generate directive 
Javascript :: graphql float 
Javascript :: discord.js bot 
Javascript :: await fetch in react 
Javascript :: number to array javascript 
Javascript :: append sibling javascript after first child 
Javascript :: create phone number javascript 
Javascript :: javascript object dont sort 
Javascript :: javascript is valid json string 
Javascript :: sum javascript 
Javascript :: moment add seconds 
Javascript :: last element in array javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =