I am new to javascript and I am trying to read a JSON file using javascript, but I do not know how to access data from the promise result. I have my data in a .json file call Data.json and I am using fetch inside in a promise to load the JSON file and return the result. How can I get the data from the promise result?
Data in JSON file
{
"data": {
"reviewer": [
{
"id": 1,
"name": "susan smith",
"job": "web developer",
"text": "I'm baby meggings twee health goth +1. Bicycle rights tumeric chartreuse before they sold out chambray pop-up. Shaman humblebrag pickled coloring book salvia hoodie, cold-pressed four dollar toast everyday carry"
},
{
"id": 2,
"name": "anna johnson",
"job": "web designer",
"text": "Helvetica artisan kinfolk thundercats lumbersexual blue bottle. Disrupt glossier gastropub deep v vice franzen hell of brooklyn twee enamel pin fashion axe.photo booth jean shorts artisan narwhal."
},
{
"id": 3,
"name": "peter jones",
"job": "intern",
"text": "Sriracha literally flexitarian irony, vape marfa unicorn. Glossier tattooed 8-bit, fixie waistcoat offal activated charcoal slow-carb marfa hell of pabst raclette post-ironic jianbing swag."
},
{
"id": 4,
"name": "bill anderson",
"job": "the boss",
"text": "Edison bulb put a bird on it humblebrag, marfa pok pok heirloom fashion axe cray stumptown venmo actually seitan. VHS farm-to-table schlitz, edison bulb pop-up 3 wolf moon tote bag street art shabby chic. "
}
]
}}
JavaScript Code
const data = new Promise((resolve, reject) => {
fetch('./Data.json')
.then(respond => {
resolve(respond.json())
}).catch(err => {
reject(err)
})
})
console.log(data)
When I run the code, I got this in the console.