Confusion around Promises exercise in JS

Hello!

I don’t know enough about Promises in javascript to be sure, but there seems to be some inconsistency around the api.request function in the api class of the Translation Service exercise. In api.js, the fetch(text) function seems to always return a Promise, while request(text, callback) seems to use the pre-Promise style of passing in a callback function to return the result asynchronously. However, the example in the instructions for that exercise imply that the api.request function only takes the parameter text and returns a Promise. Lastly, the description of api.request in the instructions matches api.js and not the example.

What is the recommended approach to raise this kind of issue at Exercism?

(PS The hint also indicates that api.request is intended to be a callback-type function and not a Promise one.)

1 Like

Asking here is fine. As we move our focus from GitHub to the forum the response time from maintainers is probably a little slower, but it’ll come. As @kotp says, probably best to post this in the programming/javascript category (I’ll move it for you).

With regards to the content, I’ll let someone from the JavaScript team reply!

1 Like

@SleeplessByte @bobahop are you able to help out @DavidOfEarth on this issue?

  • ExternalApi#fetch always returns a Promise<Translation>.
  • ExternalApi#request is a callback style function that takes a callback (as second parameter)

You are tasked to implement a service that provides (among others) a free and request function, both of which always return promises.

Lastly, the description of api.request in the instructions matches api.js and not the example.

This is indeed a problem. I see these examples were added later and the top one is incorrect as api.request never returns a Promise (whereas service.request always does). I have supplied the following PR to resolve this:

(PS The hint also indicates that api.request is intended to be a callback-type function and not a Promise one.)

It is, so that will remain.

2 Likes