UNPKG

@k-roon/homebridge-hejhome-ir

Version:
17 lines 661 B
import ky from 'ky'; export const hejRequest = async (platform, method, path, data, expectJson = true) => { const url = `https://square.hej.so/${path}`; const response = await ky(url, { method, headers: { authorization: `Bearer ${platform.token}`, 'x-requested-with': 'XMLHttpRequest', Referer: 'https://square.hej.so/square', }, /* ky는 옵션 이름이 json → json, body → rawBody */ ...(data !== undefined && { json: data }), }); const text = await response.text(); return expectJson ? JSON.parse(text || '[]') : text; }; //# sourceMappingURL=request.js.map