Skip to content

Commit 818b0db

Browse files
committed
clean up
1 parent 20d74fb commit 818b0db

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

src/api/api.js

-9
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,33 @@ const getHeaders = (authenticationToken) => ({
3030
*/
3131
export const downloadInput = async (year, day, authenticationToken) => {
3232
logger.debug('downloading input file for year: %s, day: %s', year, day);
33-
3433
if (!authenticationToken) {
3534
throw new Error(
3635
'Authentication Token is required to query advent of code.'
3736
);
3837
}
3938

40-
// query api
4139
const url = puzzleInputUrl(year, day);
4240
logger.debug('querying url for input: %s', url);
4341
const response = await fetch(url, {
4442
headers: getHeaders(authenticationToken),
4543
});
4644

47-
// bad request, authentication failed.
4845
if (response.status === 400) {
4946
throw new NotAuthorizedError();
5047
}
51-
// not found, invalid day or year.
5248
if (response.status === 404) {
5349
throw new PuzzleNotFoundError(year, day);
5450
}
55-
// handle all other error status codes
5651
if (!response.ok) {
5752
throw new InternalServerError(response.status, response.statusText);
5853
}
5954

60-
// expect text of response is the input.
6155
const text = await response.text();
62-
6356
if (!text) {
6457
throw new Error('Advent of code returned empty input');
6558
}
66-
6759
logger.debug('downloaded: %s', sizeOfStringInKb(text));
68-
6960
return text;
7061
};
7162

0 commit comments

Comments
 (0)