I am very new to Node.js and Express and have been doing a "learn as I go" scenario by building a Craigslist-style app where people can bid on jobs.

I am looking to see if this is the best approach for appending a bid to a job.

var _ = require('underscore');
var request = require('request');
var bcrypt = require('bcrypt');

module.exports = function(app, db, jwt, jwtOptions, passport) {
    app.post('/bids', function(req, res) {
        var body = _.pick(
        body.BidderId = req.user.id;

            where: {
                id: body.JobForBidId
        }).then(function(job) {
            if (job) {
                db.bids.create(body).then(function (bid){
                        status: 'failure',
                        error: err,
            } else {
                    message: 'Job not found'
        }).catch(function(err) {
                status: 'failure',
                error: err,
  • \$\begingroup\$ does db.jobPosting.findOne() return a job, a jobPosting, or something else? Perhaps it would help to include that method, or at least the return value/type. \$\endgroup\$ – Sᴀᴍ Onᴇᴌᴀ Dec 13 '17 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.