title: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services. at FirebaseAppError
body: <p>I am learning to use Firebase Cloud Function and I am following Firebase's official tutorial video for <a href="https://www.youtube.com/watch?v=7IkUgCLr5oA" rel="noreferrer">Learn JavaScript Promises (Pt.1)</a> </p>
  
  <p>When I run a local server and  go to the HTTP link I get </p>
  
  <p>Error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services.</p>
  
  <p>I tried finding the solution but couldn't find anywhere. I got some vaguely related question but for javascript and my code is in typescript. I did add the suggested syntax in both .js and .ts file</p>
  
  <pre><code>admin.initializeApp(functions.config().firebase);
  </code></pre>
  
  <p>But still, I get the same error</p>
  
  <p>Here is my index.tcs.</p>
  
  <pre><code>import * as functions from 'firebase-functions';
  import * as admin from 'firebase-admin';
  
  // Start writing Firebase Functions
  // https://firebase.google.com/docs/functions/typescript
  
  export const getVoucher = functions.https.onRequest((request, response) =&gt; {
      const promise = admin.firestore().doc('/voucher/Eg2AtnGmKmX8Y0vBZiBG').get()
      const p2 = promise.then(snapshot=&gt;{
          const data = snapshot.data()
          response.send(data)
      })
      p2.catch(error =&gt; {
          //Handlle the error
          console.log('error: '+error)
          response.status(500).send(error)
      })
  });
  </code></pre>
  
  <p>The function works as intended when deployed to firebase tho. </p>