ilokesto

prefixUrl

OpenAPI path는 보통 /로 시작하지만, raw ky는 prefixUrl이 설정된 상태에서 leading slash input을 거부합니다. Fetcher는 string URL call에서 이 mismatch를 처리합니다.

const api = createFetcher<paths>({
  prefixUrl: 'https://example.com/api',
});

await api.get('/users/{id}', {
  params: { path: { id: '42' } },
});

최종 request는 https://example.com/api/users/42로 전송됩니다.

Retry되는 경우

ky가 알려진 prefixUrl leading-slash error를 던지고 original input이 /로 시작하는 string이면, fetcher는 leading slash를 제거한 뒤 같은 call을 retry합니다.

다음은 retry하지 않습니다.

  • absolute URL string
  • URL object
  • Request object
  • custom runner에서 발생한 unrelated synchronous error

prefixUrl 제거

extend({ prefixUrl: undefined })를 호출하면 derived client에는 더 이상 prefix URL이 없습니다. 이 경우 leading slash string input은 ky behavior를 따르며 invalid URL error가 날 수 있습니다.

목차