Методы
Ответ
{ ok: false, status: 0, error: string }
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
HTTP запросы без CORS через main процесс Electron
await api.HTTP.get(url, headers?)
await api.HTTP.post(url, body, headers?)
await api.HTTP.put(url, body, headers?)
await api.HTTP.del(url, headers?)
await api.HTTP.request({ url, method, headers, body, timeout })
{
ok: boolean, // true если status 200–299
status: number,
headers: object,
data: any, // JSON если парсится, иначе string
}
{ ok: false, status: 0, error: string }
| Параметр | По умолчанию | Описание |
|---|---|---|
url | обязательно | Полный URL |
method | 'GET' | HTTP метод |
headers | {} | Заголовки |
body | — | Тело запроса |
timeout | 15000 | Таймаут в мс |
const res = await api.HTTP.get('https://api.example.com/data');
if (res.ok) api.Logger.log(res.data);
const res = await api.HTTP.post(
'https://api.example.com/track',
{ artist: 'Imagine Dragons', title: 'Bones' }
);
const res = await api.HTTP.get(
'https://api.example.com/me',
{ Authorization: 'Bearer ' + api.Storage.get('token') }
);
if (!res.ok) api.Logger.warn('Ошибка:', res.status);