server.update() vs server.get()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 07:25 AM
Hi,
I like to understand the best practice on when to use server.update() vs server.get().
From the sample widgets from Helsinki,
customer registration - used server.update()
Hello World3(it has REST calls) - used server.get().
What is the difference in functionality? I understood server.update() will feed values to input variable in server and executes the script over there.
Can I not use the same server.update() for REST API calls as well?
Using server.get() without input arguments is not sending data to input variable to server. I had to manually pass all the arguments to server like
c.server.get({ action:add_wish, name:c.data.name}).then(function(response) {}.
If I had to use server.get(), can I use server.update() first which will feed the data to input variable and then call server.get(). This will be like making 2 calls to server.
Appreciate your advise.
Thank you,
Krishna

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 08:12 AM
This is not an official answer, but in my experience I believe server.get() and server.update() are both doing GlideAjax calls to the server. I think the difference is that with server.update() you're just sending the data object back to the server as input. This would come into play if you have bound one of the properties of the data object to an input and it has changed. The server.get() allows you to specify exactly what parameters get sent back to the server as part of the input object, and then it returns the data object in the promise back.
I think if you wanted to call the REST API you would just use angular's $http service.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 03:04 PM
Thank you Brad. That helps.
I made it to work with server.update(). But curious to know what additional advantages one have over the other. This helps in choosing the right one in our code.
Greatly appreciate if any else can add their comments. Thanks.