Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the total amount of chapters of a book of a chapter from "/verses/:version/:abbrev/:chapter" #410

Open
rasteli opened this issue Aug 1, 2023 · 0 comments

Comments

@rasteli
Copy link

rasteli commented Aug 1, 2023

Is your feature request related to a problem? Please describe.
I had a chapter from the /verses/:version/:abbrev/:chapter endpoint and I needed to access the number of chapters of its book property, but surprisingly it didn't work because the book property of the chapter returned by this endpoint doesn't contain the number of chapters. I honestly don't know if that's intentional, but I find it weird since all books returned by the /books endpoint do contain a chapters property. This was a problem for me because I did not have access to a book from /books where I was trying to access the total amount of chapters from.

Describe the solution you'd like
I think the solution might just be a matter of adding a chapters property to the response of the getChapter function. E.g.

res.json({
      book: {
        ...
        chapters: book.chapters,
      },
    ...

Describe alternatives you've considered
For now, I'm searching for a book in an array containing all books from the /books endpoint, which does contain the chapters property, and adding it to an object which I'm later going to use.

const chapters = books.find(b => b.abbrev.pt === book.abbrev.pt).chapters

const data = {
  ...response.data,
  book: {
    ...response.data.book,
    chapters
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant