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.

1699350021019.png


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: 184

MichalK73

Well-Known Member
Licensed User
Longtime User
How to check authorization for a script using a previously generated token?
 
Top