How to connect a local json file and fetch data fro it?

i want to take data from the json file and show it in the the html page.(using the .js/ts file)

for example
my json file is

text.json with the following content

{
"FR30": "this is my text."
}

how to access it and show in the page?
please give code for it …Thanks in advance

Add your JSON file inside of your www folder, then you can fetch the data by using http.get and providing a link to the local file.

Sir in your tutorials you have
this.posts=data.data.children;(inside subscribe)

what should i equal this.post to with respect to the above mentioned json file data.?

And for the record i’ve learnt a lot from your tutorials sir…Thanks :slight_smile:

So when subscribing you’re passing the result into the handler, like this:

(data) => {
    console.log(data);
}

In the tutorial you’re talking about the data object that is passed in is a result from the reddit API, and contains a lot of data. To see the structure of your data just do what I’ve done above, then you will be able to see how it is structured and how to access what you need.

1 Like

Thanks Sir :relaxed: