Created
February 14, 2022 03:03
-
-
Save xiongemi/5c8c99f814947831f9db0bc00e8d24e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// at libs/services/src/models/poem-response.interface.ts | |
export interface PoemResponse { | |
title: string; | |
author: string; | |
lines: string[]; | |
linecount: string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// at libs/services/src/poetry/poetry.service.ts | |
import { PoemResponse } from "../models/poem-response.interface"; | |
const POETRY_BASE_URL = 'https://poetrydb.org/'; | |
export async function getPoemOfTheDay(): Promise<PoemResponse[]> { | |
const response: Response = await fetch(POETRY_BASE_URL + 'random', { method: 'GET' }); | |
if (response.ok) { | |
return await response.json(); | |
} | |
throw response; | |
} | |
export const poetryService = { getPoemOfTheDay }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment