UNPKG

@lingui/cli

Version:

Lingui CLI to extract messages, compile catalogs, and manage translation workflows

26 lines (25 loc) 888 B
async function post(url, request) { const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(request), }); if (!response.ok && response.status !== 400) { return { error: { response, message: `Request failed with ${response.status} ${response.statusText} status. Body: ${await response.text()}`, }, data: undefined, }; } return { data: await response.json(), error: undefined }; } export async function tioSync(request, apiKey) { return post(`https://translation.io/api/v1/segments/sync.json?api_key=${apiKey}`, request); } export async function tioInit(request, apiKey) { return post(`https://translation.io/api/v1/segments/init.json?api_key=${apiKey}`, request); }