Creating JSONP API

Hello dear wappler community superstars !

I had the need to make jsonp calls to my wappler back-end to avoid CORS policy issues.
So far, I coded a simple php file to translate json from Server Connect into jsonp.

Is there any smarter way to do this “automatically” with wappler so that there is no need to reinvent the wheel each time I need to turn a server action into an API endpoint supporting jsonp ? :slight_smile:

Thank you very much for your help !

Is this what you are looking for?

Thanks Scott !
From my understanding, this doc (and every Wappler doc I found so far) is to connect to a 3rd party API.
In this case, I want to build and serve my own one to the “public” (the other way around). :slight_smile:

Hi Jeoff,

Serving your own API to the outside world is even easier in Wappler because this is what we do with our Server Connect actions.

Each action file is an API endpoint by itself and returns standard JSON output. So it can be called from everywhere. You can also secure it fully with the included Security Provider.

Actually our own front-end framework App Connect uses the same principle in connecting - by just utilizing the Server Connect actions API and processing the JSON.

As for the CORS headers you can simply set them in the .htaccess file if needed.

2 posts were split to a new topic: Wappler projects public GIT repository

What I meant is that Wappler’s mission is to abstract us from writing code.
(Old habits die hard but… I try to code as little and follow that principle - even if it involves a steep learning curve sometimes.)

As of right now, I had to come with a homemade (and thus not bulletproof solution, more like a quickfix) to deliver the last bits of a working api.

Wether it’s jsonp or json with .htaccess with CORS policies…
It’s “point and click” easy to connect an API.
My guess was that it was as easy (or “should be” - if not implemented yet) to do the same to create one ? :wink:

Anyway, I’ll share a quick tutorial soon, detailing how to create your own “first” api with Wappler.
As I’m sure it will help some folks here that don’t come with a developer background. :slight_smile:

3 Likes

Sounds good @jeoff75 !

Are you using postman as well when creating your API?

As @George has already mentioned, Server Connect already exposes your selected data in a ready to go JSON format. This is useful if you need to access your data from another service.

If you need a full blown RESTful API, I’d take a look at one of these:

1 Like

Is there any instruction on how to accomplish serving your own APIs, George? For instance, how would someone ‘call an action file API endpoint from everywhere?’

Thanks

Hi Ted,
You can directly link to your server action / API on your server.
Either setup a route for it in the routing panel for a nice URL (not needed for NodeJS) or use it’s URL directly.

1 Like

Oh wow, that seems pretty simple. Thanks!

Hi Teodor,
How would you manage private access for these endpoints call?
Thanks

1 Like