How to use server script? Any idea?

Hi,

I think it sounds dumb but
Can anyone tell me what’s difference between “Run javascript” & “Server script”
I searched online but i didn’t understood the “Server script”?

1 Like

Hey @vajihahmed,

Serverside javascript is code that runs on a web server, as opposed to code that runs in a web browser. This type of code is typically used to create dynamic web pages that can interact with users. Client-side javascript is code that runs in a web browser and is used to make web pages more interactive.

@newhorizoncode Do you have any example of how to run this?

1 Like

Hi @vajihahmed :wave:

The Server Script is used to run JavaScript in Bubble’ server, and not in your user’s browser.

You will use it if you need to run a JavaScript snippet after an API call, for example (as there is no browser to run the JavaScript). But in general, it is always better to use the “Run JavaScript” block.

The Server Script is more complex to use and harder to debug (as you don’t have real time access to console log). And also, it can (in extreme cases) break your app as well, as some commands may “crash”/“freeze” the server (as alerted by plugin developer).

Why don’t you use the JavaScript block?!

4 Likes

Hi @rpetribu :wave:

Actually i want to create a json from database to provide as input in backend workflow.

{
Name : xyz,
DOB : 10/12/1990,
items_deliver: 3,
Adressess: [
{1.123,6.75756},{4.2345, 5.6799}
]
},{
Name : abc,
DOB : 10/04/1996,
items_deliver: 10,
Adressess: [
{1.123,6.75756},{4.2345, 5.6799}
]
},

Since “Run Javascript” is not available in Backend workflow,
So i have to use server script.

But the thing is i don’t know how to use that…
Do you know how to use that or any example will be highly appreciated…

You don’t need to use JS for that and just use what I tell you in your other topic about building JSON.

3 Likes

For all the new bubblers
Here is the response which @Jici is referring too…

3 Likes

@vajihahmed please read this…

1 Like