"Create Model " in API & Microservices is not succeeding

Tell us what’s happening:

var express = require('express');

var app = express();

var bodyParser = require('body-parser');

var jsonParser = bodyParser.urlencoded({extended:false});

var mongoose = require('mongoose');

var Schema = mongoose.Schema;

mongoose.connect(process.env.MONGO_URI,{ useNewUrlParser: true, useUnifiedTopology: true }, () => {

console.log('connected')

})

app.use(jsonParser)

app.use("/public", express.static(__dirname + "/public"));

var personSchema = new Schema({

name: {

type:String,

required: true

},

age : Number,

favoriteFoods : [String]

})

var Person = mongoose.model("Person", personSchema)

var meher = new Person({name:'Meher', age:32, favoriteFoods:["Potato", "Leafy Vegetables"]})

module.exports = app

This is not succeeding. it’s showing
“Creating an instance from a mongoose schema should succeed”
Your project link(s)

solution: https://replit.com/@meherkrishna/fcc-api-ms

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36

Challenge: Create a Model

Link to the challenge:

Hi @tmkrishna.ui !

Welcome to the forum!

It looks like you changed the starter code.

This is the starter code you need to build off of.

Since you are using replit you can use the starter project provided for you.

Hope that helps!

Thank you. It helped

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.