const express=require('express');
const cors=require('cors');
const app=express();
app.use(cors());
app.all('/json-server',(request,response)=>{
response.setHeader('Access-Control-Allow-Origin','*');
response.setHeader('Access-Control-Allow-Headers','*');
response.send('hello ajax');
});
app.listen(8000,function(){
console.log("The service has been started and port 8000 is listening.");
});
I tried to check the node installation path and global variables, and also searched for answers in other forums, but I couldn’t find a solution.