title: Extract TImestamp from the result of a Function
body: <p>So I have an interface like this:</p>
  
  <pre><code>interface Test {
      // ...
      created_at: Timestamp;
      // ...
  }
  
  </code></pre>
  
  <p>and I return an object from a function like this:</p>
  
  <pre><code>export const getTest = functions.https.onCall(async (data, context) =&gt; {
      if (!context.auth) {
          return null;
      }
  
      let snap = await admin
                   .firestore()
                   .collection('test')
                   .get();
  
      return snap.docs.map(r =&gt; ({ // Add id to the output
          id: r.id,
          ...r.data()
      })[0];
  });
  </code></pre>
  
  <p>So I should be getting the timestamp object in my application, but this is what I get in the chrome console, when I try to get the object from the function like so:</p>
  
  <pre><code>// Using AngularFireFunctions
  let result: Test = await this.fns.httpsCallable&lt;void, Test&gt;('getTest')().toPromise();
  </code></pre>
  
  <p>This is the whole content of <code>result.created_at</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/XkH9u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XkH9u.png" alt="enter image description here"></a></p>
  
  <p>When I call <code>result.created_at.toDate()</code> I get an <code>....created_at.toDate is not a function</code> error.</p>
  
  <p><strong>What can I do to change this?</strong></p>
  
  <p>This is what I am stuck with right now:</p>
  
  <pre><code>result.created_at = new Date(result.created_at._seconds * 1000);
  </code></pre>