When I store data as a JSON variable, I can normally create variables from it in JS like this:
var person = {"name":"adam"};
var name = person.name;
When I use the fetch API though to load the resource, I am unable to create variables from the data in this same way. I know the data has loaded though as I can log it and browse it in the console.
I am currently trying to do this with the following:
  var person;
        fetch(url)
          .then(res => res.json())
          .then(data => person = data)
            var name = person.name
Assuming that the (url) loads the same data as above, how would I set the 'name' variable as the 'name' field in the json file?

