Skip to content

Return whole created example #36

@oliverjam

Description

@oliverjam

function createExample(example) {
return db
.query(
"INSERT INTO examples(owner_id, language, title, example) VALUES($1, $2, $3, $4) RETURNING id",
[example.user_id, example.language, example.title, example.example]
)

It's usually a good idea to return the newly created resource from a POST request. That way a client app can show the user exactly what new thing was created. Returning the ID is good, but it means the app has to make another network request to get the rest of the properties, which is slow/inefficient.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions