javascript read json file
// Use the Fetch API & ES6
fetch('data.json')
.then(response => response.json())
.then(data => {
// Do something with your data
console.log(data);
});const fs = require('fs');
const path = require('path');
let rawdata = fs.readFileSync(path.resolve(__dirname, 'student.json'));
let student = JSON.parse(rawdata);
console.log(student);"add variable to the .json file"
const data = require('./filename')
"Then get the array from the file with a ."
"EXAMPLE"
const MyLists = require('./MemeBotLists.json')
console.log(Mylists.Memes)
"it should then put all members of the array in the logs"
Also in JavaScript:
- check if number appears odd number of times in array javascript
- installing bootstrap in angular 9
- how to get the extension from filename using javascript
- args slice discord.js
- javascript get object from array where property equals
- refresh current component angular
- parsefloat jquery
- self invoking function javascript es6
- how to call a function in react with arguments onclick
- js rounding
- angular get current route
- create moment duration
- set img src using javascript
- problem solving for loop in javascript
- how to get href value of anchor tag in jquery
- how to get today date in javascript
- open pdf in new tab javascript
- for each python json
- align left text in reactstrap
- vue js Elements in iteration expect to have 'v-bind:key' directives
- express server replit
- clearing cookie in js
- lodash merge
- node js get file name without extension