diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-04 13:35:25 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-04 13:35:25 +0100 |
| commit | d53d375d09dd86a85ffb249de1c0cc7c3b3438bc (patch) | |
| tree | 827e02f739a542e674e5d447f46ee97096f02cd7 /src/services/graphql/queries.ts | |
| parent | ab5e5f4bdf40b5bc1ccf82dc1b4aca94d5171ec3 (diff) | |
refactor: avoid useless assignement before return statement
Diffstat (limited to 'src/services/graphql/queries.ts')
| -rw-r--r-- | src/services/graphql/queries.ts | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/services/graphql/queries.ts b/src/services/graphql/queries.ts index 1cbb616..afc9f69 100644 --- a/src/services/graphql/queries.ts +++ b/src/services/graphql/queries.ts @@ -100,17 +100,13 @@ export const getPublishedPosts = async ({ const variables = { first, after, searchQuery }; const response = await fetchApi<RawPostsList>(query, variables); const formattedPosts = response.posts.edges.map((post) => { - const formattedPost = getFormattedPostPreview(post.node); - - return formattedPost; + return getFormattedPostPreview(post.node); }); - const postsList = { + return { posts: formattedPosts, pageInfo: response.posts.pageInfo, }; - - return postsList; }; export const getAllPostsSlug = async (): Promise<Slug[]> => { @@ -226,9 +222,8 @@ export const getPostBySlug = async (slug: string): Promise<Article> => { `; const variables = { slug }; const response = await fetchApi<PostBy>(query, variables); - const post = getFormattedPost(response.postBy); - return post; + return getFormattedPost(response.postBy); }; //============================================================================== @@ -328,9 +323,8 @@ export const getSubjectBySlug = async (slug: string): Promise<Subject> => { `; const variables = { slug }; const response = await fetchApi<SubjectBy>(query, variables); - const subject = getFormattedSubject(response.subjectBy); - return subject; + return getFormattedSubject(response.subjectBy); }; export const getAllSubjectsSlug = async (): Promise<Slug[]> => { @@ -437,9 +431,8 @@ export const getThematicBySlug = async (slug: string): Promise<Thematic> => { `; const variables = { slug }; const response = await fetchApi<ThematicBy>(query, variables); - const thematic = getFormattedThematic(response.thematicBy); - return thematic; + return getFormattedThematic(response.thematicBy); }; export const getAllThematicsSlug = async (): Promise<Slug[]> => { |
