abibliadigital
abibliadigital copied to clipboard
Add the total amount of chapters of a book of a chapter from "/verses/:version/:abbrev/:chapter"
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
}
}