title: Firebase Cloud Functions: how to get data from `change` and `context`?
body: <p>The <a href="https://firebase.google.com/docs/functions/beta-v1-diff" rel="nofollow noreferrer">Firebase SDK for Cloud Functions Migration Guide: Beta to version 1.0</a> documentation says that the Cloud Function trigger <code>onUpdate</code> parameters are now <code>(change, context)</code>. If I log <code>change</code> I get a object:</p>
  
  <pre><code>Change {
    before: 
     QueryDocumentSnapshot {
       _ref: DocumentReference { _firestore: [Object], _referencePath: [Object] },
       _fieldsProto: { word: [Object] },
       _readTime: undefined,
       _createTime: '2018-04-10T15:37:11.775234000Z',
       _updateTime: '2018-04-10T15:58:06.388975000Z' },
    after: 
     QueryDocumentSnapshot {
       _ref: DocumentReference { _firestore: [Object], _referencePath: [Object] },
       _fieldsProto: { word: [Object] },
       _readTime: undefined,
       _createTime: '2018-04-10T15:37:11.775234000Z',
       _updateTime: '2018-04-10T15:58:06.388975000Z' } }
  </code></pre>
  
  <p>The documentation says that I can get the data from this object with <code>change.before.val()</code> and <code>change.after.val()</code>. But logging <code>change.before.val()</code> results in this error message:</p>
  
  <pre><code>TypeError: change.before.val is not a function
  </code></pre>
  
  <p>Logging <code>change.after.val()</code> produces this error message:</p>
  
  <pre><code>TypeError: Cannot read property 'val' of undefined
  </code></pre>
  
  <p>Logging <code>context</code> results in this object, which doesn't include the data I want:</p>
  
  <pre><code>{ eventId: 'a981ffc3-a07a-4b17-8698-0f3ef6207ced-0',
    timestamp: '2018-04-10T17:03:00.699887Z',
    eventType: 'google.firestore.document.update',
    resource: 
     { service: 'firestore.googleapis.com',
       name: 'projects/languagetwo-cd94d/databases/(default)/documents/Oxford_Dictionaries/Word_Request' },
    params: { Word_Request: 'Word_Request' } }
  </code></pre>
  
  <p>Do the <code>(change, context)</code> parameters only work with Realtime Database and not with Cloud Firestore?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>exports.oxfordPronunciation = functions.firestore.document('Oxford_Dictionaries/{Word_Request}').onUpdate((change, context) =&gt; {
  
  console.log(change);
  
    let options = {
      url: 'https://od-api.oxforddictionaries.com/api/v1/entries/en/ace/pronunciations%3B%20regions%3Dus',
      headers: {
        'app_id': 'TDK',
        'app_key': 'swordfish'
      }
    };
  
    function callback(error, response, body) {
      if (!error &amp;&amp; response.statusCode == 200) {
        var word = JSON.parse(body);
        admin.firestore().collection('Oxford_Dictionaries').doc('Word_Response').set({ 'token': word });
      }
    }
  
    request(options, callback);
    return 0;
  });
  </code></pre>
  
  <p>Here are my Node modules:</p>
  
  <pre><code>npm list --depth=0 
  functions@ /Users/TDK/LanguageTwo/functions
  ├── firebase-admin@5.12.0
  ├── firebase-functions@1.0.1
  └── request@2.85.0
  </code></pre>