B4J Tutorial [Web] Using PocketBase as a Framework: Lets create a REST API

Ola.

Its amazing with the latest version of PocketBase one can extend it with JavaScript / Go.

So I tested creating some REST API handlers. You can unzip the attached file to your pocketbase folder. It should create a pb_hooks folder. You can then call the handler via the browser after starting your server.



It seems one can also do direct DB calls with this. A lot to be explored.

This is the simple code on the created js file.

B4X:
routerAdd("GET", "/api/hello/:name", (c) => {    
let name = c.pathParam("name")    
return c.json(200, { "message": "Hello " + name })
 }

Enjoy!
 

Attachments

  • pb_hooks.zip
    428 bytes · Views: 202

MichalK73

Well-Known Member
Licensed User
Longtime User
How to check authorization for a script using a previously generated token?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…