Skip to content

Config.timeout not working #10

Description

@jupegarnica

The parameter timeout it is not working either at instance creation neither as options during calling soxa.get(url, options)

I make my own cancel logic using a cancelation token, but the documentation is not rigth. I had to import CancelToken from /src/cancel/CancelToken.ts. It is not in soxa instance.

import { soxa } from 'https://deno.land/x/soxa@1.4/mod.ts';
import { CancelToken } from 'https://deno.land/x/soxa@1.4/src/cancel/CancelToken.ts';
import { REQUEST_TIMEOUT } from './config.ts';

export async function get(url: string): Promise<any> {
  let cancel: Function;
  const id: number = setTimeout(() => {
    cancel('TIMEOUT ' + REQUEST_TIMEOUT);
  }, REQUEST_TIMEOUT);

  const response: any = await soxa
    .get(url, {
      cancelToken: new CancelToken(
        (c: Function) => (cancel = c),
      ),
    })
    .finally(() => clearTimeout(id));
  return response;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions