tencent cloud

Tencent Cloud Observability Platform

http.post

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-03-11 19:41:10
http.post is used to initiate POST requests.
post(url:string, body: string | object | Record<string, string>, request?: Request): Response

Parameters

Parameter
Type
Description
url
string
URL string.
body
string, object, or Record<string, string>.
Request body.
request
Request
Optional; request object. The method, url, and body fields in the request object will not override the method, url, and body in the current method http.post.

Return

Type
Description
Response
Response object.

Samples

Initiate a POST request:
import http from 'pts/http';

export default function () {
const data = { user_id: '12345' };
const headers = { 'Content-Type': 'application/json' };
const request = {
headers,
};
const resp1 = http.post('http://httpbin.org/post', data, request);
const resp2 = http.post('http://httpbin.org/post', '123', request);
console.log(resp1.json().json.user_id); // 12345
console.log(resp2.json().json); // 123
}


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백