Start a new topic

onPreFetch not firing on $kinvey.DataStore.get

Hi There



onPreFetch is not firing when I use $kinvey.DataStore.get (appears to work fine on $kinvey.DataStore.find).



Code to demonstrate not working (i.e. rewrite the entityId):



function onPreFetch(request, response, modules){

request.entityId = "52f6eeb1279fd3ba250554cb";

response.continue();

}



Please help ASAP.



Thanks

Paul

The `entityId` is immutable, I am not sure what you’re trying to accomplish by modifying it. Can you elaborate?
I am trying to implement a Business Logic script in onPreFetch that is not working.



It works when I use $kinvey.DataStore.find

It does not work when I use $kinvey.DataStore.get



I used the entityId update in the request object (during preSave) to try to demonstrate that the code was not firing.



In any case, you should be able to replicate by create a onPreSave logic script and calling Kinvey with both a find and and get function from AngularJS.
Hi Paul,



I looked in our logs and it seems the onPreFetch is firing for requests issued by `$kinvey.DataStore.get` . You can verify this by looking at the network requests going over the wire, the response header should contain `X-Kinvey-Executed-Collection-Hooks` set to `Pre-Fetch`.



If that header is not there, can you provide me with the `X-Kinvey-Request-Id` header, which should also be part of the response?
Login or Signup to post a comment