Getting a 500 error when making HTTP post request in Angular/ Node.js

921 Views Asked by At

I was stuck when trying to make a post request with Angular httpclient, here is the code I used to export data in Angular service:

/* UPLOAD_URL = "https:/semi.edu/uploadData" */

    this.http.post(UPLOAD_URL, this.tracker.traverse_order).subscribe(
      (response) => console.log(response),
      (error) => console.log(error)
    );

And this is the code I included in app.js (node.js file):

  var db = require('./db');
  var express = require('express');
  var app = express();

  app.post('/uploadData', bodyParser.json(), (req, res) => {

    let insert_sql_statements = [...];

    db.connection.query({
      sql: 'INSERT INTO `collected_data` (articles) VALUES ?',
      values: [insert_sql_statements]
    });

And here is the error message:

Internal server error 500

And the server error log:

server log

0

There are 0 best solutions below