Access JSON that content is an object - Javascript

Asked

Viewed 37 times

-3

I am "pulling" a json into my code whose content is an object within an array. My goal is to take each attribute (news and title news) of the object and insert it into html. But the return I have in the browsed is : [Object Object]

THE JSON: [{"noticia":"https://www.moneytimes.com.br/banco-central-ira-acelerar-aumento-do-juro-para-1-ponto-percentual-avalia-itau/","titloNoticia":"Central Bank will accelerate interest increase to 1 percentage point, evaluates Itaú"}]

JS

$.getJSON('http://localhost/scraping/res.json', function(response){



const texto = document.querySelector('[data-link-noticia]');
const cont = document.createElement('a');

cont.innerHTML = response
texto.appendChild(cont);
})

I tried several ways, but in my condition of beginner in the subject I could not solve. If anyone can help, thank you

1 answer

-2


  • It worked, thanks a lot for your help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.