Properly catch user counter errors

This commit is contained in:
Ajay Ramachandran 2020-09-23 14:05:44 -04:00
parent 7c0bc9afd3
commit c6afaf81e0

View file

@ -1,4 +1,4 @@
var request = require('request');
const fetch = require('node-fetch');
const config = require('../config.js');
const getIP = require('../utils/getIP.js');
@ -6,11 +6,8 @@ const getHash = require('../utils/getHash.js');
const logger = require('../utils/logger.js');
module.exports = function userCounter(req, res, next) {
try {
request.post(config.userCounterURL + "/api/v1/addIP?hashedIP=" + getHash(getIP(req), 1));
} catch(e) {
logger.debug("Failing to connect to user counter at: " + config.userCounterURL);
}
fetch(config.userCounterURL + "/api/v1/addIP?hashedIP=" + getHash(getIP(req), 1), { method: "POST" })
.catch(() => logger.debug("Failing to connect to user counter at: " + config.userCounterURL))
next();
}