title: Why is my object's values a function and not a string?
body: <p>I have an update function for an event. It is possible that the user has added a teaser video or not. If they have I want to upload it and save that object with the download url.</p>
  
  <p>I use a different function to upload the video and only call it if the user attached a video.</p>
  
  <p>But when I try to update, it tells me that I'm trying to write an invalid object because the data in <code>teaser</code> is a function, where I want it to be a string (either the download url, or just an empty string.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>This is how I call the function:</p>
  
  <pre><code>updateEvent(values, videoAsFile, () =&gt; {
      setIsEventEdited(false);
      setCurrentEvent(values);
  })
  </code></pre>
  
  <p>Then these are the functions:</p>
  
  <pre><code>const uploadTeaserVideo = (event, video) =&gt; async () =&gt; {
    const ref = storage.ref(`/videos/events/${event.id}/`);
  
    const upload = await ref.put(video);
    if (!upload) return "";
  
    const downloadUrl = await ref.getDownloadURL();
    if (!downloadUrl) return "";
  
    return downloadUrl;
  };
  
  export const updateEvent = (values, teaserVideo, cb) =&gt; async () =&gt; {
  
    if (teaserVideo) {
      const teaser = await uploadTeaserVideo(values, teaserVideo);
      db.collection("events")
        .doc(values.id)
        .set({ ...values, teaser })
        .then(() =&gt; {
          cb();
        });
    } else {
      db.collection("events")
        .doc(values.id)
        .set(values)
        .then(() =&gt; {
          cb();
        });
    }
  };
  </code></pre>
  
  <p>I've checked, and <code>teaserVideo</code> is a valid video file, or null if a video wasn't chosen.</p>