function getDataString(request) {
  if (typeof request.data === 'number') {
    request.data = request.data.toString();
  }

  const contentType = getContentType(request.headers);

  if (contentType && contentType.includes('application/json')) {
    try {
      const parsedData = JSON.parse(request.data);
      return { data: JSON.stringify(parsedData) };
    } catch (error) {
      console.error('Failed to parse JSON data:', error);
      return { data: request.data.toString() };
    }
  } else if (contentType && (contentType.includes('application/xml') || contentType.includes('text/plain'))) {
    return { data: request.data };
  }

  const parsedQueryString = querystring.parse(request.data, { sort: false });
  // if missing `=`, `query-string` will set value as `null`. Reset value as empty string ('') here.
  // https://github.com/sindresorhus/query-string/blob/3d8fbf2328220c06e45f166cdf58e70617c7ee68/base.js#L364-L366
  Object.keys(parsedQueryString).forEach((key) => {
    if (parsedQueryString[key] === null) {
      parsedQueryString[key] = '';
    }
  });
  const keyCount = Object.keys(parsedQueryString).length;
  const singleKeyOnly = keyCount === 1 && !parsedQueryString[Object.keys(parsedQueryString)[0]];
  const singularData = request.isDataBinary || singleKeyOnly;
  if (singularData) {
    const data = {};
    data[repr(request.data)] = '';
    return { data: data };
  } else {
    return getMultipleDataString(request, parsedQueryString);
  }
}
Converts request data to a string based on its content type.

@param {Object} request - The request object containing data and headers.
@returns {Object} An object containing the data string.