Answer the question
In order to leave comments, you need to log in
API POST field - ID vs Name?
Building an API, endpoint: POST BOOK
There is a BOOK_TYPES table : 1 - 'science', 2 - 'erotic', 42 - 'novel'
(there is a GET ALL_BOOK_TYPES endpoint)
Which request body is more convenient for frontend development:
POST BOOK:
{
title: ‘Idiot’,
bookType: 42,
}
{
title: ‘Idiot’,
bookType: ‘novel’,
}
Answer the question
In order to leave comments, you need to log in
Do not care, the developer will still refer to the property of its object when assembling the request.
And id is better here, as it unifies the code ..
Add one more field to the response and get the name, type name and type ID.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question