How to read a file in React Js and convert it to object?

Viewed 39

I have a data.js file which contains data in this format:

{ 
   "name": "shehwar",
   "phone": "123"
}

Things to note: i) No Name is given to the Object ii) No Export keyword

I can't change the content of the file and nor add export keyword in the file.

How can I read the data.js file in react and convert it into object so I can use the values as object.name and object.phone

0 Answers
Related