title: Google Firebase Error(Function returned undefined, expected Promise or value)
body: <p>I'm developing Server with Firebase.</p>
  
  <p>I had copied Google Developer's Video on <a href="https://www.youtube.com/watch?v=7E13ZBCyKT0&amp;index=2&amp;list=PLl-K7zZEsYLkPZHe41m4jfAxUi0JjLgSM" rel="noreferrer">Youtube</a>.</p>
  
  <p>It works well, but on log there is an error:</p>
  
  <blockquote>
    <p>Function returned undefined, expected Promise or value</p>
  </blockquote>
  
  <p>It says function returned <code>undefined</code>, but I make <code>function</code> return a <code>promise</code> `set``</p>
  
  <p>How can I solve this?</p>
  
  <pre><code>function sanitize(s) {
      var sanitizedText = s;
      console.log('sanitize params: ', sanitizedText);
      sanitizedText = sanitizedText.replace(/\bstupid\b/ig, "wonderful");
      return sanitizedText;
  }
  exports.sanitizePost = functions.database
      .ref('/posts/{pushId}')
      .onWrite(event =&gt; {
          const post = event.data.val();
          if (post.sanitized) return;
  
          console.log('Sanitizing new post', event.params.pushId);
          console.log(post);
          post.sanitized = true;
          post.title = sanitize(post.title);
          post.body = sanitize(post.body);
          return event.data.ref.set(post); 
      })
  </code></pre>
  
  <p>I'm beginner of Firebase, Nodejs.</p>