From 9473f9d4d9425c8ad5ddaca2b86dcfd04707217e Mon Sep 17 00:00:00 2001 From: Maciej Kowalczyk Date: Tue, 23 Oct 2018 15:16:25 +0200 Subject: [PATCH] chore(): cookbook docs update --- .../cookbook/web/database/creating-objects.md | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/docs/cookbook/web/database/creating-objects.md b/docs/cookbook/web/database/creating-objects.md index 88349781..08fb2ad9 100644 --- a/docs/cookbook/web/database/creating-objects.md +++ b/docs/cookbook/web/database/creating-objects.md @@ -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) } ``` @@ -85,10 +84,10 @@ The server side is ready so now the only thing left to do, is adding a client si ```