I deployed a code to Firebase functions. Now I need the same code for another project. But I lost the code in my local machine.
Is there anyway to retrieve the code
Yes you can find your Cloud Functions code on the Google Cloud Platform console (not the Firebase console).
You can either copy/paste the code from the text area or use the "Download zip" button at the bottom of the screen.