DenoDDeno
Powered by
bAILEYB
Denoβ€’2y agoβ€’
4 replies
bAILEY

Basic CRUD API

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'))
})
 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
ctx.request.body is not a function
,
[uncaught application error]: BadRequestError - Unexpected end of JSON input
[uncaught application error]: BadRequestError - Unexpected end of JSON input
etc

Any help and/or pointers to correct documention would be really helpful, thanks! :D
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

ISOLATE_INTERNAL_FAILURE - on basic API middleware
CloudCCloud / help
9mo ago
Removing cookie for basic logout
captainbuckketsCcaptainbuckkets / help
2y ago
Twitter API
πΠπ / help
3y ago