tencent cloud

Tencent Cloud Observability Platform

http.put

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2025-03-11 19:41:10
http.put is used to initiate put requests.
put(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.put.

Return

Type
Description
Response
Response object.

Samples

Initiate a PUT 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.put('http://httpbin.org/put', data, request);
const resp2 = http.put('http://httpbin.org/put', '123', request);
console.log(resp1.json().json.user_id); // 12345
console.log(resp2.json().json); // 123
}


Ajuda e Suporte

Esta página foi útil?

comentários