How to use form-data in Request API?

The Request API can be used for form-data requests. The content-type to be used is application/x-www-form-urlencoded.

Sample request:

client.request.post("https://example.com/form", {
  headers: {"Content-Type": "application/x-www-form-urlencoded"},
  form: {
    "name": "Tony Stark",
    "age": 50,
    "occupation": ["CEO", "Consultant", "Benefactor", "Mentor"]
  }
}).then((data) => {
  //success case
}).catch((error) => {
  //failure case
});

Since Request API is built similar to request NPM, this documentation can also be referred to make use of the URL-Encoded forms in the same way.