diff --git a/components/webapi.js b/components/webapi.js index b13f062..cdc64e1 100644 --- a/components/webapi.js +++ b/components/webapi.js @@ -1,47 +1,46 @@ const SteamCommunity = require('../index.js'); SteamCommunity.prototype.getWebApiKey = function(domain, callback) { - var self = this; this.httpRequest({ - "uri": "https://steamcommunity.com/dev/apikey?l=english", - "followRedirect": false - }, function(err, response, body) { + uri: 'https://steamcommunity.com/dev/apikey?l=english', + followRedirect: false + }, (err, response, body) => { if (err) { callback(err); return; } - if(body.match(/
Key: ([0-9A-F]+)<\/p>/); - if(match) { + let match = body.match(/
Key: ([0-9A-F]+)<\/p>/); + if (match) { // We already have an API key registered callback(null, match[1]); } else { // We need to register a new API key - self.httpRequestPost('https://steamcommunity.com/dev/registerkey?l=english', { - "form": { - "domain": domain, - "agreeToTerms": "agreed", - "sessionid": self.getSessionID(), - "Submit": "Register" + this.httpRequestPost('https://steamcommunity.com/dev/registerkey?l=english', { + form: { + domain, + agreeToTerms: 'agreed', + sessionid: this.getSessionID(), + Submit: 'Register' } - }, function(err, response, body) { + }, (err, response, body) => { if (err) { callback(err); return; } - self.getWebApiKey(domain, callback); - }, "steamcommunity"); + this.getWebApiKey(domain, callback); + }, 'steamcommunity'); } - }, "steamcommunity"); + }, 'steamcommunity'); }; /**