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

fetch #157

Open
magicdawn opened this issue Mar 23, 2023 · 1 comment
Open

fetch #157

magicdawn opened this issue Mar 23, 2023 · 1 comment

Comments

@magicdawn
Copy link
Owner

No description provided.

@magicdawn
Copy link
Owner Author

magicdawn commented Mar 23, 2023

usage

修改 Request#url

Request.prototype.url 是 readonly 的, 需要 clone 一个 Request

https://stackoverflow.com/questions/34640286/how-do-i-copy-a-request-object-with-a-different-url

Request() constructor

https://developer.mozilla.org/en-US/docs/Web/API/Request/Request

new Request(input: string | Request, options?: RequestInit)
  • input 是 string or URL or Request
  • options 是覆盖项

上面 stackoverflow 问题中是将 old Request 塞到 new Request 第二个参数, 但是 body 不能带过来.

searchParams

https://stackoverflow.com/questions/35038857/setting-query-string-using-fetch-get-request

  • fetch 太难用了, 这么基础的功能还需要用户去构造 new URL('/foo/bar', { searchParams: { } })
  • ky 可以直接用 searchParams, 以为 fetch 也提供, 看到 Request 实例上没有 searchParams, 只有一个 readonly stringurl

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