title: Fetch YAML or MsgPack in Javascript (Browser)
body: <p>I know how to fetch JSON with the Fetch API like this:</p>
  <pre class="lang-js prettyprint-override"><code>fetch('http://example.com/movies.json')
    .then(response =&gt; response.json())
    .then(data =&gt; console.log(data));
  </code></pre>
  <p>I tried to replicate the same thing to get MsgPack or YAML data, but all my attempts have failed. I obviously know how to deserialize data, but I suspect I feel a bit lost with chained promises which I don't fully grasp. Since there is no response.yaml(), I need to us an extra step but I can't make it work. I tried with response.body() and response.blob(). Each time I do it, no data is available at the time of the console log. Which I assume means that my data is still a promise instead of being processed and called with the callback.</p>
  <p>I have tried things like:</p>
  <pre class="lang-js prettyprint-override"><code>fetch('http://example.com/movies.json')
    .then(response =&gt; response.body())
    .then(data =&gt; console.log(deserialize(data)));
  </code></pre>
  <p>or:</p>
  <pre class="lang-js prettyprint-override"><code>fetch('http://example.com/movies.json')
    .then(response =&gt; response.body())
    .then(raw =&gt; deserialize(raw))
    .then(data =&gt; console.log(data));
  </code></pre>
  <p>Here <code>deserialize</code> is a placeholder for the deserialize/decode function for either format.</p>
  <p>Anybody has an example using YAML (I suspect more popular than MsgPack).</p>