-
Notifications
You must be signed in to change notification settings - Fork 113
Closed
Description
- The
npmpublished version of this library does not have this issue as it is still on version2.2.1 - The
mainbranch of this library has many issues since Replacerequestandrequest-promisewithAxios#161 has merged.
This is mostly related to removal of callbackdonesupport inlib/httpClient.jsas seen here- I agree that this is overall a positive change, however this has caused many issues upstream. As all the other parts of the library still assume
donecallback is still supported inhttpClient.
An example islib/athlete.jswith:It assumes thatathlete.prototype.get = function (args, done) { var endpoint = 'athlete' return this.client.getEndpoint(endpoint, args, done) }doneis still supported ingetEndpointwhich is not the case.
Additionallyathlete.prototype.getshould be marked asasyncnow thatthis.client.getEndpointisasync.
- I agree that this is overall a positive change, however this has caused many issues upstream. As all the other parts of the library still assume
- Creating this issue to track work to update all
lib/andtest/to move toasync/awaitand removedonecallback usage.
Example:
Before (callback):
lib/athlete.js:
athlete.prototype.get = function (args, done) {
var endpoint = 'athlete'
return this.client.getEndpoint(endpoint, args, done)
}
/test/athlete.js
describe('#get()', function () {
it('should return detailed athlete information about athlete associated to access_token (level 3)', function (done) {
strava.athlete.get({}, function (err, payload) {
if (!err) {
(payload.resource_state).should.be.exactly(3)
} else {
console.log(err)
}
done()
})
})
})
After (async/await):
lib/athlete.js:
athlete.prototype.get = async function (args) {
var endpoint = 'athlete'
return await this.client.getEndpoint(endpoint, args)
}
/test/athlete.js
describe('#get()', function () {
it('should return detailed athlete information about athlete associated to access_token (level 3)', async () => {
const response = await strava.athlete.get({})
response.resource_state.should.be.exactly(3)
})
})
Metadata
Metadata
Assignees
Labels
No labels