Untitled
unknown
typescript
2 years ago
797 B
7
Indexable
import * as https from 'https';
import * as fs from 'fs';
// Путь к файлу сертификата
const certificatePath = '/path/to/certificate.crt';
// Опции запроса, включая путь и другие параметры
const options: https.RequestOptions = {
hostname: 'api.example.com',
path: '/api/endpoint',
method: 'GET',
// Загрузка сертификата
ca: fs.readFileSync(certificatePath),
};
// Создание запроса
const req = https.request(options, (res) => {
// Обработка ответа
res.on('data', (data) => {
console.log(data.toString());
});
});
// Обработка ошибок запроса
req.on('error', (error) => {
console.error(error);
});
// Отправка запроса
req.end();Editor is loading...