DEV Community

loading...

Discussion on: Sharing state using React's Context API

Collapse
srbin12 profile image
miodrag

Hi, do you wish help me in next problem. My code:

function noviData() {

fetch("http://localhost:3000/posts.json")
    .then(response => {
        return response.json();
    })
    .then(data => {
        console.log("parsed json of function noviData", data);
        //alert([json.name, json.id, json.email]);
    })
    .catch(function(ex) {
        console.log("parsing failed", ex);
    });

}
How can use data of this function from some another function or component or const or context?
If you have some advice or tutorial examples.
Regard
Mr.Miodag