Answer the question
In order to leave comments, you need to log in
RestAPI, routes, relationships, models?
Greetings Toaster Members!
If we take for example the following scheme of relations between posts and pictures (OneToMany):
Posts
title
content
Images
src
post_id
{
"status": "success",
"images": [
{
"id": 1,
"src": "/uploads/foo.png"
},
{
"id": 2,
"src": "/uploads/bar.png"
}
]
}
{
"status": "success",
"id": 1
}
Answer the question
In order to leave comments, you need to log in
There are no specifications in the rest, there is a dissertation from which everything went, and a bunch of different format variations that are promoted for use, for example, here is how one of the formats suggests solving your problems: https://jsonapi.org/format/#crud-updating- resource... In some project it is so convenient, in some it is not convenient, in some you need something else.
Whether he is full or not is not important at all, and in the original there were no json, it seems that at that time it had not even been invented yet. Therefore, do as it is convenient, send and receive in a format that is convenient (almost all frameworks correctly process json, xml and form data out of the box), and all this reasoning about rest is like talking about what oop is.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question