Friday, 23 March 2018

Question to Express API response

Hey,I've build an API to post data with express.It is just a query to my DB for now. If I start the query from my web page the query will be on "pending" all the time. It loads, loads and loads. Everything I've sent to update in my db is updated, but for some reasons on my webpage it is still pending.heres some code: router.post('/test/clear', (req, res) => { var sql_test= "UPDATE test SET ? = '' WHERE name = ?"; pool.getConnection((err, con) => { pool.query(sql_test, [db_col, obj.clear.test], function(err, results) { if(err) throw err; else { res.statusCode = 201; res.json(results); } }); con.release(); }); }); I tried to google my problem and tried to solve my problem with sending something back within my "else", but after saving it just shows the json, instead of the webpage. My goal is to not reload the webpage after saving and not having a pending status. Do you know how to fix this problem?

Submitted March 23, 2018 at 03:11PM by oppoi

No comments:

Post a Comment