title: EXPRESS js : Urls giving incorrect contents
body: <p>I have the node server server.js and two other js files where am fetching data courses (courses.js) and reviews (reviews.js)</p>
  <p><b><code>Server.js</code></b></p>
  <pre><code>  const express = require('express');
   //import express from 'express';
  
   const bodyParser = require('body-parser');
   //import bodyParser from 'body-parser';
  
   const pino = require('express-pino-logger')();
  //import pino from 'express-pino-logger';
  
   //const courses =require('./courses');
  //import courses from './courses'
  //import *  as courses from './courses';
  
  var PORT = process.env.PORT || 8000;
  
  const app = express();
  
  app.use(bodyParser.urlencoded({ extended: false }));
   app.use(pino);
  app.use(express.json());
  app.use(express.urlencoded());
  
  
  
  
   //Get all reviews
  
   const reviews= require(&quot;./reviews&quot;);
  
   app.get(&quot;/reviews&quot;, async(req,res)=&gt;{
   console.log(reviews);
    let result =  await reviews (req.headers);
    res.send(result);
   });
  
  
  
   //REST API Call
  
   app.get(&quot;/&quot;,async (req, res)=&gt;{
   res.send(&quot;Hello Node,js ! Change the authorization header in the courses&amp;reviews. Put in your 
     Authorization token from udemy affiliate api-2.0 &quot;)
   }) 
  
  
   //Get all courses
  
   const courses= require(&quot;./courses&quot;);
  
   app.get(&quot;/courses&quot;, async(req,res)=&gt;{
   console.log(courses);
    let result =  await courses (req.headers);
    res.send(result);
    });
  
  
    app.listen(PORT, () =&gt;{
      console.log(`Server is started and listening on port: ${PORT}`)
   })
  </code></pre>
  <p>courses.js</p>
  <pre><code> const fetch = require('node-fetch');
  
   url = 'https://www.udemy.com/api-2.0/courses';
  
  
       module.exports=  async  function courses() {
      try{
       const request= await fetch(url,{
              method:'GET',
              credentials:&quot;same-origin&quot;,
              headers:{
              &quot;Authorization&quot;:&quot;xxxxxxxxx&quot;,
              &quot;redirect&quot;:&quot;follow&quot;,
              &quot;referrerPolicy&quot;:&quot;no-referrer&quot;,
              &quot;Permissions-Policy&quot;:&quot;interest-cohort =()&quot;,
              &quot;Accept&quot;:&quot;application/json, text/plain, */*&quot;,
              'Content-Type': 'application/json,  charset=utf-8',
              &quot;credentials&quot;:&quot;same-origin&quot;,
              &quot;cache&quot;:&quot;no-cache&quot;
              }
             
              
              
           })
            .then(function(response){
                //console.log(response)
                return response.json();
            })
            .then(function(data){
               // console.log(data);
               return data;
            })
          return request;  
      }
      catch(e){
          console.log(&quot;We have an error&quot;)
          console.log(e)
      }
       }
  </code></pre>
  <p>reviews.js</p>
  <pre><code>  const fetch = require('node-fetch');
  
    url = 'https://www.udemy.com//api-2.0/courses/1723848/reviews';
  
  
       module.exports=  async  function reviews() {
      try{
       const request= await fetch(url,{
              method:'GET',
              credentials:&quot;same-origin&quot;,
              headers:{
              &quot;Authorization&quot;:&quot;xxxxxxx&quot;,
              &quot;redirect&quot;:&quot;follow&quot;,
              &quot;referrerPolicy&quot;:&quot;no-referrer&quot;,
              &quot;Permissions-Policy&quot;:&quot;interest-cohort =()&quot;,
              &quot;Accept&quot;:&quot;application/json, text/plain, */*&quot;,
              'Content-Type': 'application/json,  charset=utf-8',
              &quot;credentials&quot;:&quot;same-origin&quot;,
              &quot;cache&quot;:&quot;no-cache&quot;
              }
             
              
              
           })
            .then(function(response){
                //console.log(response)
                return response.json();
            })
            .then(function(data){
               // console.log(data);
               return data;
            })
          return request;  
      }
      catch(e){
          console.log(&quot;We have an error&quot;)
          console.log(e)
      }
     }
  </code></pre>
  <p>When I visit /courses I get the course content but when I visit /reviews I get still get the course content . Sometimes the contents reverse and I get reviews on both urls</p>