How to use the ky-universal function in ky-universal

To help you get started, we’ve selected a few ky-universal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github filestack / filestack-js / src / lib / api / request.ts View on Github external
return new Promise(async (resolve) => {
    let response;

    try {
      response = await ky(url, payload);
    } catch (error) {
      if (error.name === 'AbortError') {
        console.log('errror aborted');
      } else {
        console.log('fetch error', error);
      }
    }
    console.log(response);
    let headers = {};

    if (response.ok) {
      const data = await response.body();

      response.headers.forEach((value, name) => {
        headers[name] = value;
      });
github node-gitlab / node-gitlab / src / core / infrastructure / KyRequester.ts View on Github external
KyRequester[m] = async function(service, endpoint, options) {
    const requestOptions = defaultRequest(service, { ...options, method: m });
    let response;

    try {
      response = await Ky(endpoint, requestOptions);
    } catch (e) {
      if (e.response) {
        const output = await e.response.json();

        e.description = output.error || output.message;
      }

      throw e;
    }

    const { status } = response;
    const headers = responseHeadersAsObject(response);
    const body = await processBody(response);

    return { body, headers, status };
  };