Cannot make integration API calls

Hi guys… I cannot make api calls via integration to the backend server running on localhost… I always get network error or some internal error.

Please help me with this… So, I have a Next plasmic Project … working as both frontend & backend… But I cant make integration api calls from plasmic studio to my backend server

Hey @illuminating_egret! Unfortunately, this is not possible.

The data queries runs in the plasmic server so we don’t have access to your localhost.

The data queries run on the Plasmic server, so we don’t have access to your localhost.
However, you can use the HTTP REST API Fetcher component, which runs in the browser, to achieve this. You’ll need to host the Plasmic app within your own app. You can find more information on how to host Plasmic Studio in your app in the documentation here: https://docs.plasmic.app/learn/app-hosting/

Let me know if this helps you

Screen Shot 2023-11-21 at 11.25.22.png

Hi @samuel wouldn’t that create exposed API keys on the front end? What is the recommended approach to secure this or work with this component? I realise this is a localhost setup so no risk but if this was pushed live then you could technically find the API keys in the browser dev tools

@empirical_scallop That’s correct. You basically need to decide what you want, whether you want the api calls to go through our back end or not. If they go through our back end, then we need to be able to reach the final API endpoint, and auth is taken care of. If they go through your browser, then either the API endpoint is public, or you are relying on your own cookie/session auth - this should be no different than if you are pretending that plasmic doesn’t exist, what would you do. Let me know if that makes sense.

1 Like

Thanks Yang… Makes sense, was just wondering if I was missing something obvious.

Hello all,

is there a way to determine when the api call is actually made? Like on the click of a button or the submission of a form. I want to be able to catch error messages and display them as a notification.

You can add conditional actions to your interactions to display notifications on error. You can read more about conditional actions here: Interactions and state reference | Learn Plasmic

Hello Sarah,

Thanks for your response.
I understand the concept behind interactions and state.
There is a REST API component in Plasmic. When you add it to your page, it instantly makes the api request. What I really want to know is whether or not it is possible to control when the api request is actually made.

@AdditionalKingKicker, I believe you wanted to add Use Integration action to your click listener, like here:

You’ll first need to create a backend integration.

And here is the next item you would likely be curious about: How to send a post request to my server and then do something with the response?

This has been very helpful. Thank you very much.

1 Like