添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am a student and as part of the assignment, I am developing an weather app that connects to openweatherapp website and retrieves the data. When executing this from command prompt as nodemon index.js, I am getting the following error.

ReferenceError: mongoose is not defined at Object. (C:\Users\anand\Desktop\Sem 4\web apps\Assignment 3\2298917_193294482_708854\708854\app\index.js:7:18)

The code for index.js is

var http = require('http');
var express = require('express')
var app = express();
app.set('view engine', 'ejs');
var city = 'Las Vegas';
mongoose.connect('mongodb://prettyprinted:Password11@ds253879.mlab.com:53879/express_weather')
var citySchema = new mongoose.Schema({
    name: String
var request = require('request');
//http.createServer(function (request, response) {
    //var request = require('request');
var url = 'http://api.openweathermap.org/data/2.5/weather?q=London&appid=7970f50f59ddccaf607b8a4890574039';
app.get('/', function (req,res) {
    request(url, function (error, response, body) {
        weather_json = JSON.parse(body);
        console.log(weather_json);
        var weather = {
            city: city,
            //temperture: Math.round(weather_json.main.temp),
            Descrip: weather_json.weather[0].description,
            icon: weather_json.weather[0].icon
        var weather_dat = {weather : weather};
        res.render('weather', weather_dat);
    //res.render('index')
app.listen(11223);

Please advise.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.