Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config.timeout not working #10

Open
jupegarnica opened this issue Dec 6, 2020 · 1 comment
Open

Config.timeout not working #10

jupegarnica opened this issue Dec 6, 2020 · 1 comment

Comments

@jupegarnica
Copy link

jupegarnica commented Dec 6, 2020

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/[email protected]/mod.ts';
import { CancelToken } from 'https://deno.land/x/[email protected]/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;
}
@jupegarnica
Copy link
Author

Actually, this approach is not working anyway. Just to let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant