Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

[Bug] 'baseURL' ignored while using 'axiod(config)' #27

Open
KaKi87 opened this issue Sep 27, 2022 · 5 comments
Open

[Bug] 'baseURL' ignored while using 'axiod(config)' #27

KaKi87 opened this issue Sep 27, 2022 · 5 comments

Comments

@KaKi87
Copy link

KaKi87 commented Sep 27, 2022

const axiodOrAxios = typeof axiod !== 'undefined' ? axiod : typeof axios !== 'undefined' ? axios : undefined;

const client = axiodOrAxios.create({ baseURL: 'https://httpstat.us' });
await client.get('/200');
console.log('Success');
await client({ url: '/200' });
console.log('Success');

Expected output (axios-like) :

Success
Success

Actual output :

Success
error: Uncaught (in promise) TypeError: Invalid URL
  return fetch(url, fetchRequestObject).then(async (x) => {
         ^
    at opUrlParse (deno:ext/url/00_url.js:52:26)
    at new URL (deno:ext/url/00_url.js:331:20)
    at new Request (deno:ext/fetch/23_request.js:307:27)
    at deno:ext/fetch/26_fetch.js:433:29
    at new Promise (<anonymous>)
    at fetch (deno:ext/fetch/26_fetch.js:429:20)
    at Function.request (https://deno.land/x/axiod@0.26.2/mod.ts:252:10)
    at Object.axiod (https://deno.land/x/axiod@0.26.2/mod.ts:23:16)

Thanks

@roonie007
Copy link
Owner

@KaKi87 can open a PR ?

@KaKi87
Copy link
Author

KaKi87 commented Oct 7, 2022

I am requesting this fix but am not qualified to do it myself, sorry.

@hrishikesh-k
Copy link

I just came across the same problem and created a PR: #30 which can potentially fix it. It's not the best or the cleanest solution, but given how it's currently setup, that's the only way I could come up with. Please review and merge it, so I can use it in production! 😄

@KaKi87
Copy link
Author

KaKi87 commented Jul 4, 2023

Actually, I'm now using import axios from 'npm:axios', which Deno began supporting a few versions ago.

Thanks anyway

@hrishikesh-k
Copy link

Oh you're right, we could just use axios directly! I totally forgot!

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

Successfully merging a pull request may close this issue.

3 participants