How to read data from a JSON file into HTML | json to html js 2024

Опубликовано: 21 Октябрь 2024
на канале: Mazen Salah
514
8

This video shows you how to load data from a json file into html using vanilla javascript.

Developers typically search: how to read json data in html, or how to read file data in javascript. Other programmers want some exact things such as reading json to html table, or reading json to html list. Loading data from json to js requires you to use the http or https protocol, I explained this in the video and showed how to install the extension "live server" that permits you to open your html project using http in order to be able to load json into html, so you won't have the problem of a json file not working in javascript and you won't face the error of "index.html:1 Access to fetch at '/ SOME PATH /' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted."

Fetching a json file is one of the most important things that a developer should be able to perform. So there is not a programmer that doesn't know how to fetch a json file into JavaScript because that would be inevitable when using an api. But you don't have to worry anymore! Because this video teaches you how to read json in html using the JavaScript built-in function "fetch" that returns a response and promise.