soxa
soxa copied to clipboard
Config.timeout not working
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;
}
Actually, this approach is not working anyway. Just to let you know.