Created
April 24, 2020 09:11
-
-
Save corbin88/fd18415a79caf5b2997e82fe47898d14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm building a small CRUD app that keeps track of students: | |
**Mongo Model** | |
var StudentSchema = new mongoose.Schema({ | |
first: String, | |
last: String, | |
teacher: String, | |
classroom: String, | |
major: String, | |
minor: String, | |
updated_date: { type: Date, default: Date.now }, | |
}); | |
The repsponse is outputting in html and not JSON | |
**Express router** | |
router.get('/', function(req, res, next) { | |
Book.find(function (err, products) { | |
if (err) return next(err); | |
res.json(products); | |
}); | |
}); | |
**Student List Component** | |
created () { | |
axios.get(`/student`) | |
.then(response => { | |
console.log(response.data); | |
this.students = response.data | |
}) | |
.catch(e => { | |
this.errors.push(e) | |
}) | |
}, | |
What keeps happening is every time I call the "students" route to get a list of all of the students is I get `reponse.data` returning as html instead of JSON. | |
**Console error** | |
>s.foreach is not a function //ADD HTML RESPONSE HERE AARON | |
**What Arron needs to add** | |
- Console.log(response.data) html error from browser console |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment