title: Why am I getting empty array in fetch request to MongoDB from ReactJS?
body: <p>I am trying to fetch all the articles from a document in MongoDB in React. It is perfectly working in Backend with NodeJS when I tested with Postman. But in Frontend , React, I am getting empty array. How to solve this.</p>
  <h1>Server.js (Backend)</h1>
  <pre><code>app.get('/api/articles', async (req, res)=&gt;{
      const client = await MongoClient.connect('mongodb://localhost:27017', {useNewUrlParser:true, useUnifiedTopology:true})
      const db = client.db('my-blog')
  
      const articleInfo= await db.collection('articles').find({}).toArray(function(err, result){
          if (err) console.log(err)
          res.status(200).send(result)
          client.close()
      })
      
  })
  </code></pre>
  <h1>articlePage.js (FrontEnd)</h1>
  <pre><code>componentDidMount(){
          const requestOptions = {
              method: 'GET',
              headers: { 'Content-Type': 'application/json' },
          };
          const fetchdata = fetch('/api/articles/').then(res=&gt;res.json())
          .then(data=&gt;this.setState({articles:data}))
          console.log(this.state.articles)
  
      }
  </code></pre>
  <p>Api address is set up in package.json with <code>proxy:http://localhost:8000</code></p>
  <p>How to get the documents data from MongoDB in React?</p>