Getting Started example not working

67 views
Skip to first unread message

Johnny Tee

unread,
Feb 19, 2017, 9:50:41 AM2/19/17
to LoopbackJS
Hi LoopBackers,
I am attempted the getting started tutorial, but I seem to keep getting an error when trying to POST with the API Explorer GUI. 
I have tried creating more models, but still no luck, any ideas?
Here is what I get in my shell :

Browse your REST API at http://localhost:3000/explorer
Unhandled error for request POST /api/CoffeeShops: ValidationError: The `CoffeeShop` instance is not valid. Details: `id` can't be set (value: 0).
    at E:\loopback\node_modules\loopback-datasource-juggler\lib\dao.js:323:12
    at ModelConstructor.<anonymous> (E:\loopback\node_modules\loopback-datasource-juggler\lib\validations.js:502:11)
    at ModelConstructor.next (E:\loopback\node_modules\loopback-datasource-juggler\lib\hooks.js:83:12)
    at ModelConstructor.<anonymous> (E:\loopback\node_modules\loopback-datasource-juggler\lib\validations.js:499:23)
    at ModelConstructor.trigger (E:\loopback\node_modules\loopback-datasource-juggler\lib\hooks.js:73:12)
    at ModelConstructor.Validatable.isValid (E:\loopback\node_modules\loopback-datasource-juggler\lib\validations.js:465:8)
    at E:\loopback\node_modules\loopback-datasource-juggler\lib\dao.js:319:9
    at doNotify (E:\loopback\node_modules\loopback-datasource-juggler\lib\observer.js:99:49)
    at doNotify (E:\loopback\node_modules\loopback-datasource-juggler\lib\observer.js:99:49)
    at doNotify (E:\loopback\node_modules\loopback-datasource-juggler\lib\observer.js:99:49)
    at doNotify (E:\loopback\node_modules\loopback-datasource-juggler\lib\observer.js:99:49)
    at Function.ObserverMixin._notifyBaseObservers (E:\loopback\node_modules\loopback-datasource-juggler\lib\observer.js:122:5)
    at Function.ObserverMixin.notifyObserversOf (E:\loopback\node_modules\loopback-datasource-juggler\lib\observer.js:97:8)
    at Function.ObserverMixin._notifyBaseObservers (E:\loopback\node_modules\loopback-datasource-juggler\lib\observer.js:120:15)
    at Function.ObserverMixin.notifyObserversOf (E:\loopback\node_modules\loopback-datasource-juggler\lib\observer.js:97:8)
    at Function.ObserverMixin._notifyBaseObservers (E:\loopback\node_modules\loopback-datasource-juggler\lib\observer.js:120:15)

Erin McKean

unread,
Feb 19, 2017, 12:10:16 PM2/19/17
to LoopbackJS
It looks like this model will insert an "id" for you; what happens if you try to POST without an id property?

Mark Johnson

unread,
Feb 19, 2017, 5:57:51 PM2/19/17
to LoopbackJS
Loopback3 won't let you specify the ID for a new instance unless you set forceId to false in that model's configuration.

Raymond Feng

unread,
Feb 20, 2017, 3:17:11 PM2/20/17
to LoopbackJS
Do you have a fresh checkout from https://github.com/strongloop/loopback-getting-started? If so, the forceId is already set to false by https://github.com/strongloop/loopback-getting-started/commit/cf067254b4d64fb25b9fdd0a1707a85038fad00f. I confirm it works for me.

Thanks,
Raymond

On Feb 19, 2017, at 2:57 PM, Mark Johnson <mjohn...@gmail.com> wrote:

Loopback3 won't let you specify the ID for a new instance unless you set forceId to false in that model's configuration.

--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/2c11b967-0213-4b9f-8d73-edc5d222edf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages