Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions docs/cookbook/web/database/creating-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ Edit file `syncano/hello-world/src/hello.js` and change its content to:
```js
import Syncano from '@syncano/core'

export default (ctx) => {
export default async (ctx) => {
const { data, response } = new Syncano(ctx)
const { title, pages } = ctx.args

data.book.create({ title, pages })
.then(bookObj => {
response.json({msg: `Book with ID ${bookObj.id} created!`})
}).catch(({ data, status }) => response.json(data, status))
const book = await data.book.create({
title: ctx.args.title,
pages: ctx.args.pages
})
response.json(book)
}
```

Expand All @@ -85,10 +84,10 @@ The server side is ready so now the only thing left to do, is adding a client si
<script>
const s = new SyncanoClient('YOUR_INSTANCE')

s.post('hello-world/hello', { title: 'PeterPan', pages: 334 })
.then(res => {
console.log(res.msg)
})
s.post('hello-world/hello', { title: 'Godfather', pages: 446 })
.then(res =>
console.log(`Book with ID ${res.id} created!`)
)
</script>
```

Expand Down