News application api link not fetching a data

I have been trying to fetch a data using a url from news.org but it’s not fetching a data . Please HELP!!! Attaching browser image for reference

Here is my code :

let collapseWidthExample = document.getElementById('collapseWidthExample');
 let source = 'dawn-news';

 fetch('https://newsapi.org/v2/everything?q=tesla&from=2021-07-09&sortBy=publishedAt&apiKey=')
     .then(response => {
         return response.json(); /*here the data  we are getting in form of json*/

     }).then(Array)

 .catch(function(err) {
     console.log(err);
 });
 let news =
     `<div style="min-height: 120px;">
 <div class="collapse collapse-horizontal" id="collapseWidthExample">
     <div class="card card-body py-4" style="width: 300px;">
         This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered.
     </div>
 </div>
</div>
<p>
 <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseWidthExample" aria-expanded="false" aria-controls="collapseWidthExample">
Toggle width collapse
</button>
</p>
<div style="min-height: 120px;">
 <div class="collapse collapse-horizontal" id="collapseWidthExample">
     <div class="card card-body py-4" style="width: 300px;">
         This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered.
     </div>
 </div>
</div>

The response has status 200 OK, but what is this supposed to do:

.then(Array)

I would rather expect something like:

.then(data => {
  console.log(data) // does this log anything?
})

Thank you for the reply… the issue has been resolved now…

Cool, what was the problem?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.