Skip to content

Commit 8a09eff

Browse files
author
Lauren Connors
committed
update PVP Team to use async/await syntax
1 parent 7e23112 commit 8a09eff

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

lib/pvpteam.js

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,18 @@ class PvPTeam extends Lib {
1212
page int optional
1313
}
1414
*/
15-
search(name, params = {}) {
16-
return new Promise((resolve, reject) => {
17-
if(typeof(name) === 'undefined')
18-
reject(this.throwError('pvpteam.search()', 'a name'))
19-
20-
this.req(
21-
'/pvpteam/search',
22-
Object.assign(params, {name:name})
23-
).then((res) => {
24-
resolve(res)
25-
}).catch((err) => {
26-
reject(err)
27-
})
28-
})
15+
async search(name, params={}) {
16+
if(typeof name==="undefined")
17+
throw this.throwError(`PvPTeam.search()`, 'a name');
18+
19+
return this.req(`/pvpteam/search`,Object.assign({}, params, {name}));
2920
}
3021

31-
get(id) {
32-
return new Promise((resolve, reject) => {
33-
if(typeof(id) === 'undefined')
34-
reject(this.throwError('pvpteam.get()', 'an ID'))
35-
36-
this.req('/pvpteam/' + id).then((res) => {
37-
resolve(res)
38-
}).catch((err) => {
39-
reject(err)
40-
})
41-
})
22+
async get(id) {
23+
if(typeof id==="undefined")
24+
throw this.throwError(`PvPTeam.get()`, 'an ID');
25+
26+
return this.req(`/pvpteam/${id}`);
4227
}
4328
}
4429

0 commit comments

Comments
 (0)