Not finding the name in the object

Viewed 24

I'm creating a quote generator, and im trying to get the author. I'd think its response.originator.name but it pulls up an error. enter image description here

Then i tried response[1].name and it just pulls up a undefined response

Here is the code

enter image description here

1 Answers

.then is used to get the result of a Promise, you can't just keep calling it to a execute another line of code.

Promise.prototype.then()

fetch(url)
.then(response => response.json())
.then(response => {
    quote.innerText = response.content;
    name.innerText = response.originator.name;
 })
 .catch(err => console.error(err));
Related