My node js program is giving me a “TypeError: Cannot read property 'then' of undefined”, when reading a json file
问题 I'm trying to read frpm a json file folder withing my program and i want to use a GET list endpoint to read through browser or postman, but i'm getting the above TypeError. Here is my code: model.js: const fs = require('fs'); function loadTeams() { return new Promise((resolve, reject) => { fs.readFile('./json/prov-nodes.json', (err, data) => { if (err) reject(err); const teams = JSON.parse(data); console.log(teams); resolve(teams); }); }); } app.use(bodyParser.json()); app.get('/list', (req,