title: NodeJS (ExpressJS) Unhandled rejection TypeError: callback is not a function
body: <p>I've been learning to use <strong>Angular 6</strong> and <strong>NodeJS</strong> (with <strong>ExpressJS</strong>) these past few days. To do this, I decided to create a front-end with <strong>Angular 6</strong> (o which theres a form) with the intention of passing information back and forth to my <strong>PHPMyAdmin</strong> database via the use of an API I created with <strong>NodeJS</strong>.
  As you may have seen from the title, I get the following error when I try to submit my forms information: </p>
  
  <blockquote>
    <p>"<em>Unhandled rejection TypeError: callback is not a function</em>"</p>
  </blockquote>
  
  <p>The code I used for the post action was taken from another functioning and similar API, the database receives the question_id and user_id but will not register the questions answers (which is the end goal).
  Without furthur ado, here is the code to get and post:</p>
  
  <pre><code>const config = require('../config/config');
  const knex      = config.db.knex;
  const async     = require('async');
  
  
  class TestModel {        
    getQuestions(callback) {
          knex('question')
          .select('id', 'libelle')
      .orderBy('id', 'asc')
          .then((data) =&gt; {
              callback(data);
          });
      }
  
  
    addResponse(reponse, callback) {
        knex('reponse')
        .insert({
            id_user : 1,
            id_question : reponse.id,
            libelle: reponse.answer,
        }).then((data) =&gt; {
            callback(data);
          });
    }        
  }
  
  
  module.exports = new TestModel();
  </code></pre>
  
  <p>Here is the rest:</p>
  
  <pre><code>app.post('/quiz', function(req, res, next){
      var answers = req.body;
  
      console.log(answers)
  
      for(var i = 0; i&lt;answers.length; i++)
          {
              var obj = answers[i];
              Test.addResponse((obj,result) =&gt; {
  
              });                
          }        
      res.json({reponseserveur:'True'});    
  });
  </code></pre>
  
  <p>Just for reference, "reponse" means response and "libelle" means label.
  Thanks in advance for your help!</p>