0

I am planning to use Firebase as my backend service for the mobile application. As part of the functionality, I need to get the data from external rest API which returns JSON data. I need to update the data periodically so that I can have updated information.

I have an option to call the rest API and update firebase on the mobile application however it is not the right approach. I prefer to keep this logic on the backend service.

Is there a way to use Firebase cloud function to periodically update firebase database from external Rest API?

Lokesh
  • 1,144
  • 1
  • 10
  • 18
  • This might be useful for you: https://github.com/firebase/functions-cron – Michael Bleigh Jun 23 '17 at 19:28
  • Thanks for the pointer. This will help me trigger the call periodically. I am not sure how to call a rest API to get the JSON data in cloud function. Could you provide some examples? – Lokesh Jun 23 '17 at 19:33
  • Cloud Functions are just Node.js code. See e.g. https://stackoverflow.com/questions/5643321/how-to-make-remote-rest-call-inside-node-js-any-curl – Michael Bleigh Jun 23 '17 at 19:49
  • I m a newbie to firebase. I did not know that it is a node.js function. I will try it out, thanks again for your help. – Lokesh Jun 23 '17 at 20:04

1 Answers1

0

@Ioki, I assume what you are trying to do is make a mobile app which gets updated data every time a user goes to the app but you want this to be on the backend. I haven't tried it but you might want to use Node js with their Firebase Admin SDK. See the link: https://firebase.google.com/docs/admin/setup

Although I think it might make more sense to use the real-time database via the iOS/ Android SDK because automatic/ value event updates are basically the purpose of the real- time database. Good luck! :)

Mihir Thanekar
  • 508
  • 4
  • 8