fixing json responses

This commit is contained in:
Arjun Patel
2019-01-15 11:44:23 -08:00
parent f90561af31
commit b453c78c00
2 changed files with 10 additions and 4 deletions
+8 -4
View File
@@ -1,10 +1,11 @@
const db = require('../config/db.config.js'),
bcrypt = require('bcrypt-nodejs');
bcrypt = require('bcrypt-nodejs'),
errorMaker = require('../helpers/error.maker');
const Donors = db.donors;
// Create/post a Donor
exports.create = (req, res) => {
exports.create = (req, res, next) => {
// see if user already in db
Donors.findAll({
where: {
@@ -50,10 +51,13 @@ exports.create = (req, res) => {
};
// FETCH all Donors
exports.findAll = (req, res) => {
exports.findAll = (req, res, next) => {
Donors.findAll().then(donors => {
// Send all donors to Client
res.status(200).send(donors);
res.status(200).json({
donors,
number_donors: donors.length
});
});
};
+2
View File
@@ -5,6 +5,8 @@ const express = require('express'),
port = process.env.PORT,
db = require('./app/config/db.config.js');
console.log(process.env.JAWSDB_MARIA_URL);
app.use(bodyParser.json());
//handle CORS errors