'How do I write a firebase function to run once every 24 hours [duplicate]

I’m building a JavaScript(react native) application with firebase, and the idea is I want to write a function in firebase that makes a couple of API requests to an external api and then stores the data in Firestore, how ever I want this to happen once every 24 hours, or whenever some certain attributes in a specific users data (Users collection) changes so essentially this data rendered to the user changes every 24 hours, any tips on how I can approach this problem ?



Solution 1:[1]

exports.scheduledFunction = functions.pubsub.schedule('every 24 hours').onRun((context) => {
  console.log('This will be run every 24 hours!');
  return null;
});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1