How to use “await” in sails when creating a new record

前端 未结 2 1816
醉酒成梦
醉酒成梦 2021-01-14 12:17

I want to use \"await\"

According to the sails documentation I act as follows:
https://sailsjs.com/documentation/reference/waterline-orm/models/create

<
2条回答
  •  星月不相逢
    2021-01-14 12:59

    I think you should make your function async.

     async(function(){
       var new_place = await Place.create({...})
    })();
    

    And if you are using await you should not use callbacks. You should manage the response as explained here

    Also you can check this guide of how to manage async in sail.js

提交回复
热议问题