Custom code block -> Send API call to another api

Hello!
What’s the best way to send an API call from a custom code block?
I need to include an API key or some way to validate the request is coming from Softr, and also get some data about the user such as their username or company name.
Is there a way to access data about the user or send some data I can use to validate if they’re logged in or anything like that?
I assume that including the API key in the custom code would be a bad security practice.

Thank you

Hi @cleveland and welcome to the community!

If I understand correctly, the key thing you are looking for is a way to validate that a request you are receiving is coming from a web page where there is a valid logged-in user of Softr.

If I needed to do this, I’d pass the Softr authentication token in the request, and on the code handling the request, I’d call the Softr API to validate an authentication token.

The authentication token is available in a cookie called jwtToken.

In JavaScript code, you can retrieve properties of the logged-in user from the window.logged_in_user object.

Does this work for you?

Thank you. I will try this out.