refactor(Elife): Use async / await
@@ -3,14 +3,11 @@ interface ArticleData {
}
export default {
- query: (id: string, fetcher: Function): Promise<ArticleData> => {
- return fetcher(`https://api.elifesciences.org/articles/${id}`).then(
- (data: ArticleData) => {
+ query: async (id: string, fetcher: Function): Promise<ArticleData> => {
+ const data = await fetcher(`https://api.elifesciences.org/articles/${id}`)
if (data.status === 404) {
throw new ReferenceError(`Invalid eLife article id: ${id}`)
}
- return { status: data.status }
- }
- )
+ return Promise.resolve({ status: data.status })
}
}
