title: JS HTTP post YAML
body: <p>I am unable to post a yaml throught http in js. The code works when I used JSON.stringify(text) for body and have content-type application/json. If I use YAML stringify, body on server side is just {}.
  I have areatext where I enter a text (like yaml format) in html e.g.</p>
  <pre><code>martin:
    name: Martin D'vloper
    job: Developer
    skill: Elite
  </code></pre>
  <p>Client:</p>
  <pre><code>$('#create-yaml2').on('click',async function () {
      var text = $('#yaml-create').val();
      // console.log(text)
      var textYAML = YAML.stringify(text);
      var options = {
        hostname: 'myhostname',
        port: 80,
        path: `/api/postyaml`,
        method: 'POST',
        body: textYAML,
        headers: {
          'Content-Type': 'text/x-yaml'
        }
      };
      var executeReq = http.request(options);
      executeReq.write(textYAML);
      executeReq.end();
    });
  </code></pre>
  <p>EDIT:
  Function in server side, that prints not an empty {} when posting JSON.</p>
  <pre><code>exports.functionCalled = async function (req, res) {
      console.log('\n\n\n\n')
      console.log(req.body)
      console.log('\n\n\n\n')
      try {
          res.send(`RECEIVED`);
        } catch (upgradeErr) {
          res.status(422).json({
            message: `Failed`,
            error: upgradeErr
          });
      }
  }
  </code></pre>