title: Firebase Cloud Functions error_: variable is not defined
body: <p>I get this error:</p>
  
  <pre><code>ReferenceError: userid is not defined
    at exports.onUserNickUpdate.functions.firestore.document.onWrite (/srv/index.js:49:34)
      at cloudFunctionNewSignature (/srv/node_modules/firebase-functions/lib/cloud-functions.js:120:23)
      at /worker/worker.js:825:24
      at &lt;anonymous&gt;
      at process._tickDomainCallback (internal/process/next_tick.js:229:7)
  </code></pre>
  
  <p>When I run this function(gets triggered by write on document):</p>
  
  <pre><code>exports.onUserNickUpdate = functions.firestore.document('user/{userid}').onWrite((change,context) =&gt; {
  
      const changednick = change.after.data().nick
  
      return highscore_collection.doc(userid).set({
          nick: changednick
      })
  })
  </code></pre>
  
  <p>Error is from this line <code>highscore_collection.doc(userid).set</code>. I don't understand this error, how come userid is not defined?</p>