Este es mi archivo Json data.json, quiero que estos datos se obtengan mediante fetch o axios y devuelvan los datos a la variable
{"list":[ { "rank":"1", "points":"1025", "name":"John Doe", "age":"27" }, { "rank":"3", "points":"245", "name":"Elizabeth", "age":"17" }, { "rank":"2", "points":"566", "name":"Samantha", "age":"22" }]}Quiero que estos datos completos se asignen a una variable, la salida debería ser
const data= {"list":[ { "rank":"1", "points":"1025", "name":"John Doe", "age":"27" }, { "rank":"3", "points":"245", "name":"Elizabeth", "age":"17" }, { "rank":"2", "points":"566", "name":"Samantha", "age":"22" }]}await fetch("/path/to/data.json") .then(res => res.json()) .then((json) => { console.log(json) });