tencent cloud

Performance Testing Service

Related Agreements
Service Level Agreement
Use Limits
Privacy Policy
Data Processing And Security Agreement
DokumentasiPerformance Testing Service

FormData Overview

Mode fokus
Ukuran font
Terakhir diperbarui: 2025-03-10 17:04:49
FormData is used to construct a request body of the form-data type.

Constructor

Create an object instance using new, as shown below:
new FormData(): FormData

Methodology

Methodology
Return Type
Description
append(key, value)
void
Add key-value pair data to form-data.
body()
ArrayBuffer
Return the form-data content, and further append operations are not allowed.
contentType()
string
Return the ContentType of form-data.

Samples

import http from 'pts/http';

const data = open('./sample/tmp.js');

export default function () {
// Construct a FormData instance using new.
const formData = new http.FormData();
formData.append('text', 'text');
formData.append('file', http.file(data, 'tmp.js'));
console.log(formData.contentType());
const resp = http.post('http://httpbin.org/post', formData.body(), {
headers: {'Content-Type': formData.contentType()}
});
console.log('formData: ', resp.body);
};


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan