-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
How can fetch function work with a base url? #4439
Comments
What would you expect to happen? |
Ref #203 as well. |
The only way thing that would makes sense is for it to work relative to cwd (or the fs root for absolute paths), the resource resolution root. so ref #2150 and see #4038 (comment) onwards. |
I recently tried to use deno as my testing tool for a web server project. I want to reuse the front-end SDK library, which uses a lot of this kind URL: async verify (params: Object) {
let url = "/baas/auth/v1.0/resetpassword/step?step=verify";
const resp = await fetch (url, {
method: "POST",
headers: {
"content-type": "application / json"
},
credentials: "same-origin",
body: JSON.stringify (params)
});
const data = await resp.json ();
if (data.resCode! == "0") {
throw data;
}
return resp.headers.get ("reset-password-token");
} I want to call the verify function directly in the deno test code. I don't want to modify the verify function because there are many similar functions of this kind. |
@saibing Sure, I appreciate the goal, but where should deno get the response for "/baas/auth/v1.0/resetpassword/step?step=verify" ? There's no obvious choice for where to send the request to. |
const response = await fetch("./instagram.json") console.log(response); error: Uncaught URIError: relative URL without a base |
Forgot about this issue. Update: this is answered and blocked by #4981. Any relative URL (an origin-less absolute path is still a relative URL) should be relative to |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
this code worked in browser but does not in deno. deno will output as follow:
The text was updated successfully, but these errors were encountered: