#Basic CRUD API

1 messages · Page 1 of 1 (latest)

exotic dirge
#

Hi all, I'm trying to move from Node/Express and so I'm trying to use Deno/Oak for this, as I've heard Oak is pretty good. It's not going so well, I'm trying to create a basic post request for a user account creation but I'm struggling to find documentation on how to do this.

 router.post("/register", async (ctx) => {

    const body = await ctx.request.body({type: 'json'}).value()
    const value = await body.value
    console.log(value)

   // const username = user.value.get('username')
//   console.log(user.get('username'))
})```

This is some of the stuff I've tried so far but I keep getting different errors such as `ctx.request.body is not a function`, `[uncaught application error]: BadRequestError - Unexpected end of JSON input` etc

Any help and/or pointers to correct documention would be really helpful, thanks! :D
#

I'm just trying to access the request body currently ^^

exotic dirge
#

For example, in the docs, this is all I can find on Router.post and this doesn't help

wispy karma
#
router.post("/register", async (ctx) => {

    const body = ctx.request.body({type: 'json'})
    const value = await body.value
    console.log(value)

   // const username = user.value.get('username')
//   console.log(user.get('username'))
})

I think you don't have to await the request's body.