As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Javascript SDK modify request body or params when fetching data
P
Phil K
started a topic
almost 7 years ago
Hey guys.
Been looking around and can't find an answer.
Is it possible add parameters to the body{} or params{} of the request when fetching data (using stream.subscribe) using javascript sdk?
Want to pull params out at PreFetch
Cheers
Phil
Best Answer
P
Pranav J
said
almost 7 years ago
Phil,
With what I understood of the question, you can build a query using the$kinvey.Query() and add your parameters to it.
In your prefetch, you can read these query params, use the specific parameter sent for your own decision making and remove it from the query, and then let the remaining query execute.
With what I understood of the question, you can build a query using the$kinvey.Query() and add your parameters to it.
In your prefetch, you can read these query params, use the specific parameter sent for your own decision making and remove it from the query, and then let the remaining query execute.
Thanks,
Pranav
Kinvey
P
Pranav J
said
almost 7 years ago
Phil,
Yes, can you give me an example of what you want to achieve?
Thanks,
Pranav
Kinvey
P
Phil K
said
almost 7 years ago
Awesome
I want to send an object containing session specific information to catch and use in preFetch.
Use Case:
Collection that contains reports
User can open a report (which retrieves the data). As they edit it in the browser the app will periodically update the server with the data.
To prevent another user opening the same report and doing the same thing, or the same user having it open in other windows and creating crazy versioning issues all other reports are set to read only. To this I apply a "lock" to the data which will set their window to read only unless it matches the session info. What I wanted to do is check if the doc has the "lock" flag on preFetch and if not set the lock using the session info passed in params or body.
Hope that makes sense?
That and handy to know how to send params with fetch and save requests.
P
Pranav J
said
almost 7 years ago
Phil,
Yes, you should be able to pass params into requests and access them in the preFetch() hook using request.params variable.
Phil K
Hey guys.
Been looking around and can't find an answer.
Is it possible add parameters to the body{} or params{} of the request when fetching data (using stream.subscribe) using javascript sdk?
Want to pull params out at PreFetch
Cheers
Phil
With what I understood of the question, you can build a query using the $kinvey.Query() and add your parameters to it.
In your prefetch, you can read these query params, use the specific parameter sent for your own decision making and remove it from the query, and then let the remaining query execute.
Thanks,
Pranav
Kinvey
- Oldest First
- Popular
- Newest First
Sorted by PopularPranav J
With what I understood of the question, you can build a query using the $kinvey.Query() and add your parameters to it.
In your prefetch, you can read these query params, use the specific parameter sent for your own decision making and remove it from the query, and then let the remaining query execute.
Thanks,
Pranav
Kinvey
Pranav J
Yes, can you give me an example of what you want to achieve?
Thanks,
Pranav
Kinvey
Phil K
Awesome
I want to send an object containing session specific information to catch and use in preFetch.
Use Case:
Collection that contains reports
User can open a report (which retrieves the data). As they edit it in the browser the app will periodically update the server with the data.
To prevent another user opening the same report and doing the same thing, or the same user having it open in other windows and creating crazy versioning issues all other reports are set to read only. To this I apply a "lock" to the data which will set their window to read only unless it matches the session info. What I wanted to do is check if the doc has the "lock" flag on preFetch and if not set the lock using the session info passed in params or body.
Hope that makes sense?
That and handy to know how to send params with fetch and save requests.
Pranav J
Yes, you should be able to pass params into requests and access them in the preFetch() hook using request.params variable.
Please take a look at
http://devcenter.kinvey.com/angular/reference/business-logic/reference.html#request
Let me know if you need additional help.
Thanks,
Pranav
Kinvey
Phil K
Hi Pranav
Sorry I should have explained better. Accessing them with BL is fine. I wasn't sure how to send them using the Javascript SDK
i.e.
If I am fetching using:
How do I pass in params?
Thanks for your help. Sorry if I am missing something obvious
-
How do I use Kinvey in my web app?
-
Is it safe to include keys/secrets in my client-side JavaScript app?
-
Why is the activeUser null even though I am logged in?
-
Login does not work even though credentials are valid.
-
Social login doesn’t work.
-
Appending objects to an Array (HTML5 - JS)
-
New to node.js - need bootstrap to downloadfiles from Kinvey
-
Problem with Aggregation/Grouping
-
Internal Server Error using Twitter Sign Up
-
Data Store
See all 315 topics