title: Node.js - Express & mysql TypeError: res.json is not a function although insert is successful
body: <p>Although I have a successful insert I get an error (TypeError: res.json is not a function) when I want to return a json message upon. This is my setup:</p>
  
  <pre><code>const express = require('express');
  
  module.exports = {
      signup: async (req, res, next) =&gt; {
  
          const { email, username, password } = req.value.body;
  
          const connection = require('../config/dbconnection');
  
          connection.query("SELECT * FROM tbl_users WHERE email = ?",[email], function(err, rows) {
              if (rows.length) {
                  return res.json({ err: 'Email already exist'});
              } else {
  
                  var newUserMysql = {
                      email: email,
                      username: username,                 
                      password: password  
                  };
  
                  var insertQuery = "INSERT INTO tbl_users ( email, username, password ) values (?,?,?)";
  
                  connection.query(insertQuery,[newUserMysql.email, newUserMysql.username, newUserMysql.password],function(err, res, rows) {
  
                      if(err){
                          console.log('Insert error');
                          //res.json({ err: 'Insert error'});
                      } else {
                          console.log('Insert successful');
                          return res.json({ 'success': 'Insert successful'});
                          //return done(null, newUserMysql);
                      }
  
                  });
              }
          });
  
  }
  </code></pre>
  
  <p>How can I return a json on successfull insert?   </p>