Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js reading file

// get the file
fetch("path/to/file.extension")
	// get the text within the file
	.then((res) => res.text())
	// if you are reading from a json file:
	// .then((res) => res.json())
	// do something with the text
	.then((fileContents) => console.log(fileContents));
Source by web.dev #
 
PREVIOUS NEXT
Tagged: #js #reading #file
ADD COMMENT
Topic
Name
2+1 =