swarmapp-api
Advanced tools
Comparing version 1.0.4 to 1.0.6
114
main.js
@@ -5,2 +5,5 @@ const _ = require('lodash'); | ||
// some functions willl not work if the oauth_token was generated through an application created after 2021. | ||
// you may use a man in the middle proxy to detect your mobile app oauth token | ||
class SwarmappApi { | ||
@@ -20,12 +23,18 @@ constructor(config) { | ||
const params = { | ||
client_id: client_id, | ||
client_secret: client_secret, | ||
username: username, | ||
password: password, | ||
grant_type: 'password', | ||
}; | ||
const response = await axios.post(this.basePath + '/oauth2/access_token', null, { params }); | ||
this.config.access_token = response.data.access_token; | ||
return response.data.access_token; | ||
client_id: client_id, | ||
client_secret: client_secret, | ||
username: username, | ||
password: password, | ||
grant_type: 'password', | ||
}; | ||
try { | ||
const response = await axios.post(this.basePath + '/oauth2/access_token', null, { params }); | ||
this.config.access_token = response.data.access_token; | ||
return response.data.access_token; | ||
} catch (error) { | ||
console.error("Error occured", error) | ||
return; | ||
} | ||
} | ||
@@ -45,5 +54,8 @@ | ||
const result = await axios.get(this.basePath + 'users/' + options.user_id + '/friends', { 'params': this.config }); | ||
return result.data.response.friends; | ||
try { | ||
const result = await axios.get(this.basePath + 'users/' + options.user_id + '/friends', { 'params': this.config }); | ||
return result.data.response.friends; | ||
} catch (error) { | ||
console.error("Error occured", error) | ||
} | ||
} | ||
@@ -64,3 +76,7 @@ | ||
return this.getUser(options); | ||
try { | ||
return this.getUser(options); | ||
} catch (error) { | ||
console.error("Error occured", error) | ||
} | ||
} | ||
@@ -78,5 +94,9 @@ | ||
const result = await axios.get(this.basePath + 'users/' + options.user_id, { 'params': this.config }); | ||
return result; | ||
try { | ||
const result = await axios.get(this.basePath + 'users/' + options.user_id, { 'params': this.config }); | ||
return result; | ||
} catch (error) { | ||
console.error("Error occured", error) | ||
return; | ||
} | ||
} | ||
@@ -97,4 +117,9 @@ | ||
const result = await axios.get(this.basePath + 'users/' + options.user_id + '/checkins', { 'params': this.config }); | ||
return result; | ||
try { | ||
const result = await axios.get(this.basePath + 'users/' + options.user_id + '/checkins', { 'params': this.config }); | ||
return result; | ||
} catch (error) { | ||
console.error("Error occured", error) | ||
return; | ||
} | ||
} | ||
@@ -114,6 +139,9 @@ | ||
}); | ||
const response = await axios.get(this.basePath + '/users/' + options.user_id + '/checkins', { 'params': this.config }); | ||
return response.data; | ||
try { | ||
const response = await axios.get(this.basePath + '/users/' + options.user_id + '/checkins', { 'params': this.config }); | ||
return response.data; | ||
} catch (error) { | ||
console.error("Error occured", error) | ||
} | ||
} | ||
@@ -140,10 +168,15 @@ | ||
const result = await axios.get(this.basePath + 'checkins/recent', { | ||
'params': this.config, | ||
paramsSerializer: params => { | ||
return querystring.stringify(params); | ||
} | ||
}); | ||
return result.data.response.recent; | ||
try { | ||
const result = await axios.get(this.basePath + 'checkins/recent', { | ||
'params': this.config, | ||
paramsSerializer: params => { | ||
return querystring.stringify(params); | ||
} | ||
}); | ||
return result.data.response.recent; | ||
} catch (error) { | ||
console.error("Error occured", error) | ||
return; | ||
} | ||
} | ||
@@ -154,4 +187,10 @@ | ||
this.config.venueId = location_id; | ||
const result = await axios.post(this.basePath + 'checkins/' + '/add', querystring.stringify(this.config)); | ||
return result; | ||
try { | ||
const result = await axios.post(this.basePath + 'checkins/' + '/add', querystring.stringify(this.config)); | ||
return result; | ||
} catch (error) { | ||
console.error("Error occured", error) | ||
return; | ||
} | ||
} | ||
@@ -178,4 +217,9 @@ | ||
async likeCheckin(checkin_id) { | ||
const result = await axios.post(this.basePath + 'checkins/' + checkin_id + '/like', querystring.stringify(this.config)); | ||
return result; | ||
try { | ||
const result = await axios.post(this.basePath + 'checkins/' + checkin_id + '/like', querystring.stringify(this.config)); | ||
return result; | ||
} catch (error) { | ||
console.error("Error occured", error) | ||
return; | ||
} | ||
} | ||
@@ -200,3 +244,3 @@ | ||
} catch (error) { | ||
console.error(error); | ||
console.error("Error occured", error); | ||
} | ||
@@ -203,0 +247,0 @@ } |
{ | ||
"name": "swarmapp-api", | ||
"version": "1.0.4", | ||
"version": "1.0.6", | ||
"description": "A javascript wrapper for swarmapp (foursquare) API", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13908
294