본문 바로가기
뒤로
공지사항
닫기

GitHub - Sindresorhus/ky:

페이지 정보

작성자 Cathy 작성일 26-07-27 23:50 조회 8 댓글 0

본문

hqdefault.jpg

Sindre's open supply work is supported by the neighborhood. Ky targets modern browsers, Node.js, Bun, and Deno. It's just a tiny bundle with no dependencies. This readme is for the following version of Ky. For the present version, click right here. If you're using Deno, import Ky from a URL. The input and options are the identical as fetch, with extra options obtainable (see below). Returns a Response object with Body strategies added for agreement political party comfort. So you possibly can, for example, name ky.get(input).json() instantly without having to await the Response first. When called like that, an appropriate Accept header shall be set relying on the physique method used. Available physique shortcuts: .json(), .text(), .formData(), .arrayBuffer(), .blob(), and .bytes(). The .bytes() shortcut is only present when the runtime helps Response.prototype.bytes(). ⌨️ TypeScript: Accepts an optionally available kind parameter, which defaults to unknown, and is passed via to the return type of .json(). This throws a SchemaValidationError when validation fails. Sets options.technique to the tactic identify and makes a request.


11.webp⌨️ TypeScript: Accepts an non-compulsory type parameter to be used with JSON responses (see ky()). Same as fetch enter. When using a Request instance as enter, any URL altering options (reminiscent of baseUrl) might be ignored. HTTP technique used to make the request. Internally, the standard strategies (GET, Post, PUT, PATCH, HEAD, DELETE, and Query) are uppercased in an effort to avoid server errors resulting from case sensitivity. Shortcut for sending JSON. Use this instead of the body possibility. Accepts any plain object or value, which shall be stringified utilizing JSON.stringify() and despatched within the physique with the proper header set. Search parameters to include in the request URL. Setting it will merge with any existing search parameters in the enter URL. Accepts any worth supported by URLSearchParams(). When passing an object, setting a worth to undefined deletes the parameter, whereas null values are preserved and transformed to the string 'null'. A base URL to resolve the input in opposition to. When the enter (after making use of the prefix option) is barely a relative URL, akin to 'users', '/users', or '//my-site.com', it is going to be resolved towards the baseUrl to find out the vacation spot of the request.


Otherwise, the input is absolute, akin to 'https://my-site.com', and it'll bypass the baseUrl. Useful when used with ky.lengthen() to create niche-specific Ky cases. If the baseUrl itself is relative, it will be resolved in opposition to the setting's base URL, reminiscent of doc.baseURI in browsers or location.href in Deno (see the --location flag). Tip: When setting a baseUrl that has a path, we advocate that it embrace a trailing slash /, as in '/api/' quite than /api. This ensures more intuitive conduct for web page-relative enter URLs, such as 'users' or './users', the place they will extend from the total path of the baseUrl reasonably than changing its final path phase. A prefix to prepend to the enter earlier than making the request (and before it's resolved towards the baseUrl). It may be any legitimate path or URL, either relative or absolute. A trailing slash / is non-compulsory and will probably be added mechanically, if needed, when it's joined with input. Only takes effect when input is a string.


Useful when used with ky.prolong() to create area of interest-particular Ky situations. Normally, it's best to use the baseUrl option instead, as it is extra in line with net requirements. However, prefix is beneficial in order for you origin-relative enter URLs, comparable to /users, to be treated as in the event that they have been web page-relative. In other phrases, the leading slash of the input will basically be ignored, as a result of the prefix will change into part of the enter before URL decision occurs. The prefix and enter are joined with a slash /, and slashes are normalized on the be part of boundary by trimming trailing slashes from prefix and main slashes from input. After prefix and input are joined, the result's resolved towards the baseUrl option, if present. Controls retry habits. Each area is documented individually below. If retry is a number, it will likely be used as restrict and other defaults will remain in place. Network errors (e.g., DNS failures, connection refused, offline) are mechanically retried for retriable methods.


Only errors acknowledged as network errors are retried; different errors (e.g., programming bugs) are thrown instantly. Use shouldRetry to customize this habits. 413 Payload Too Large is barely retried when the response features a retry timing header. When the response standing is contained in both statusCodes and afterStatusCodes, Ky makes use of retry timing headers to choose the retry delay. Retry-After could present a delay in seconds or an HTTP-date. If Retry-After is missing, Ky falls back to price-limit timing headers (RateLimit-Reset, X-RateLimit-Retry-After, X-RateLimit-Reset, and X-Rate-Limit-Reset). Numeric Retry-After and X-RateLimit-Retry-After values are interpreted as delay seconds. Numeric RateLimit-Reset, X-RateLimit-Reset, and X-Rate-Limit-Reset values could even be interpreted as current-era Unix timestamps. If the status code shouldn't be in afterStatusCodes, retry timing headers will likely be ignored. If the retry delay from a retry timing header is higher than maxRetryAfter, Ky will use maxRetryAfter. The backoffLimit option is the upper restrict of the delay per retry in milliseconds.

댓글목록 0

등록된 댓글이 없습니다.

공지사항
TOP

세컨로드(2ndRoad) 정보

개인정보 이용약관 운영정책 청소년 보호정책
고객상담 070-4045-4134 운영시간: AM 10:00 ~ PM 05:00 (주말 및 공휴일 제외.) Copyright © 2001-2024 COREACOMMERCE.CO,.LTD. All Rights Reserved.

회사명 COREACOMMERCE.CO,.LTD
사업자등록번호 0127-02-013943
주소 2F,2-16-10, Tanashicho Nishitokyo-shi, Tokyo, JAPAN

고객상담 070-4045-4134 운영시간: AM 10:00 ~ PM 05:00 (주말 및 공휴일 제외.) Copyright © 2001-2024 COREACOMMERCE.CO,.LTD. All Rights Reserved.