{"id":474073,"date":"2025-09-05T21:00:31","date_gmt":"2025-09-05T21:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=474073"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=474073","title":{"rendered":"<span>Safe-fetch 1.0: \u043e\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0437\u0430 72 \u0447\u0430\u0441\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0422\u0440\u0438 \u0434\u043d\u044f \u043d\u0430\u0437\u0430\u0434 \u044f \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e safe-fetch \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0431\u0438\u0440\u0430\u0435\u0442 try\/catch \u0438\u0437 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412\u0447\u0435\u0440\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u0431\u0440\u0430\u043b\u0430 8,5K \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432 \u0438 64 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u043a\u043b\u0430\u0434\u043a\u0438. \u0410 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e safe-fetch 1.0 \u2014 \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0430 \u0446\u0435\u043b\u0443\u044e \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0443.<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/943732\/\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e<\/a><\/p>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0444\u0438\u0434\u0431\u0435\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0437\u0430 72 \u0447\u0430\u0441\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u043d\u0430\u0434 fetch \u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e HTTP.<\/p>\n<h3>\u041a\u0430\u043a \u0432\u0441\u0451 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c<\/h3>\n<p>1 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b safe-fetch 0.1.0 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u044e. \u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u0432\u043c\u0435\u0441\u0442\u043e try\/catch \u0432\u0435\u0437\u0434\u0435 \u2014 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438.<\/p>\n<pre><code class=\"typescript\">\/\/ \u0411\u044b\u043b\u043e try {   const res = await fetch('\/users');   if (!res.ok) throw new Error(`HTTP ${res.status}`);   const data = await res.json(); } catch (e) {   console.error('\u0427\u0442\u043e-\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c:', e.message); }  \/\/ \u0421\u0442\u0430\u043b\u043e const result = await safeFetch.get&lt;User[]&gt;('\/users'); if (result.ok) {   console.log(result.data); } else {   console.error(result.error.name); \/\/ NetworkError | TimeoutError | HttpError } <\/code><\/pre>\n<p>4 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u044b\u0448\u043b\u0430 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435. 5 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f \u2014 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u2014 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u044e 1.0 \u0441 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439.<\/p>\n<h3>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0437\u0430 \u0442\u0440\u0438 \u0434\u043d\u044f<\/h3>\n<h4>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0432\u0437\u043e\u0440\u0432\u0430\u043b\u0430\u0441\u044c<\/h4>\n<ul>\n<li>\n<p><strong>8,5K \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432<\/strong> \u0437\u0430 \u043f\u0435\u0440\u0432\u044b\u0435 \u0441\u0443\u0442\u043a\u0438<\/p>\n<\/li>\n<li>\n<p><strong>64 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u043a\u043b\u0430\u0434\u043a\u0438<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>30 \u0437\u0432\u0435\u0437\u0434<\/strong> \u043d\u0430 GitHub<\/p>\n<\/li>\n<li>\n<p><strong>70 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0439<\/strong> \u0441 NPM<\/p>\n<\/li>\n<li>\n<p><strong>2 \u043f\u0443\u043b\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442\u0430<\/strong> \u043e\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u0432 <strong>Awesome TypeScript<\/strong><\/p>\n<\/li>\n<\/ul>\n<h4>\u0424\u0438\u0434\u0431\u0435\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0431\u044b\u043b\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>&#171;\u041a\u0430\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 React Query?&#187;<\/p>\n<\/li>\n<li>\n<p>&#171;\u0410 \u0434\u043b\u044f SWR \u0431\u0443\u0434\u0435\u0442?&#187;<\/p>\n<\/li>\n<li>\n<p>&#171;\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u044d\u0442\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u043d\u043e\u0440\u0435\u043f\u043e?&#187;<\/p>\n<\/li>\n<li>\n<p>&#171;\u041d\u0443\u0436\u0435\u043d ESLint plugin \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 { ok }&#187;<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e: \u043e\u0434\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u041d\u0443\u0436\u043d\u0430 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430.<\/p>\n<h3>Safe-fetch 1.0: \u0441\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u2014 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044e 1.0.0. \u041d\u0435 \u043d\u043e\u0432\u044b\u0435 \u0444\u0438\u0447\u0438, \u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b:<\/p>\n<h4>\u041c\u043e\u043d\u043e\u0440\u0435\u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h4>\n<p>\u041f\u0435\u0440\u0435\u0435\u0437\u0434 \u0432 workspace \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438:<\/p>\n<pre><code>packages\/ \u251c\u2500\u2500 core\/                 # @asouei\/safe-fetch   \u2514\u2500\u2500 react-query\/          # @asouei\/safe-fetch-react-query <\/code><\/pre>\n<h4>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u0435\u043a<\/h4>\n<ul>\n<li>\n<p><strong>Vite + Vitest<\/strong> \u0432\u043c\u0435\u0441\u0442\u043e custom build<\/p>\n<\/li>\n<li>\n<p><strong>GitHub Actions<\/strong> \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0441\u0440\u0430\u0437\u0443<\/p>\n<\/li>\n<li>\n<p><strong>ESM\/CJS<\/strong> \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u044b \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u044b<\/p>\n<\/li>\n<\/ul>\n<h4>Zero breaking changes<\/h4>\n<p>\u0412\u0435\u0441\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"typescript\">const result = await safeFetch.get('\/api\/data'); \/\/ \u0422\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0432 0.1.0 <\/code><\/pre>\n<h3>\u041d\u043e\u0432\u0438\u043d\u043a\u0430: React Query \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/h3>\n<p>\u0421\u0430\u043c\u044b\u0439 \u0447\u0430\u0441\u0442\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043a\u0430\u0441\u0430\u043b\u0441\u044f React Query. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u0430: React Query \u043e\u0436\u0438\u0434\u0430\u0435\u0442 throws, safe-fetch \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>{ ok: false }<\/code>.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445<\/h4>\n<p>\u0412 React Query \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0431\u0440\u043e\u0441\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u043b\u044f \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438:<\/p>\n<pre><code class=\"typescript\">const { data, error } = useQuery({   queryFn: async () =&gt; {     const response = await fetch('\/users');     if (!response.ok) throw new Error('Failed');     return response.json();   } }); <\/code><\/pre>\n<p>\u0421 safe-fetch \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0434\u0435\u043b\u0430\u0442\u044c unwrap \u0432\u0440\u0443\u0447\u043d\u0443\u044e:<\/p>\n<pre><code class=\"typescript\">const { data, error } = useQuery({   queryFn: async () =&gt; {     const result = await safeFetch.get&lt;User[]&gt;('\/users');     if (!result.ok) throw result.error; \/\/ \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u0440\u0443\u0447\u043d\u0443\u044e     return result.data;   },   retry: false \/\/ \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c }); <\/code><\/pre>\n<h4>\u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/h4>\n<p>\u0412\u0441\u0442\u0440\u0435\u0447\u0430\u0439\u0442\u0435 <code>@asouei\/safe-fetch-react-query@0.1.0<\/code>:<\/p>\n<pre><code class=\"bash\">npm install @asouei\/safe-fetch-react-query <\/code><\/pre>\n<pre><code class=\"typescript\">import { createQueryFn, rqDefaults } from '@asouei\/safe-fetch-react-query';  const queryFn = createQueryFn(api);  const { data, error } = useQuery({   queryKey: ['users'],   queryFn: queryFn&lt;User[]&gt;('\/users'),   ...rqDefaults() \/\/ { retry: false } + \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 });  \/\/ error \u0442\u0435\u043f\u0435\u0440\u044c typed: NetworkError | HttpError | TimeoutError | ValidationError <\/code><\/pre>\n<h4>\u0427\u0442\u043e \u0434\u0430\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/h4>\n<ol>\n<li>\n<p><strong>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 unwrap<\/strong>: <code>{ ok: false }<\/code> \u2192 <code>throw error<\/code><\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438<\/strong>: TypeScript \u0437\u043d\u0430\u0435\u0442 \u0442\u0438\u043f \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 React Query<\/p>\n<\/li>\n<li>\n<p><strong>\u0424\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/strong>: <code>createQueryFn<\/code>, <code>createMutationFn<\/code><\/p>\n<\/li>\n<li>\n<p><strong>\u0423\u043c\u043d\u044b\u0435 \u0434\u0435\u0444\u043e\u043b\u0442\u044b<\/strong>: <code>rqDefaults()<\/code> \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0442\u0440\u0430\u0438<\/p>\n<\/li>\n<\/ol>\n<h3>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435<\/h3>\n<h4>\u0420\u0430\u043d\u044c\u0448\u0435: boilerplate \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0445\u0443\u043a\u0435<\/h4>\n<pre><code class=\"typescript\">function useUsers() {   return useQuery({     queryKey: ['users'],     queryFn: async () =&gt; {       const result = await safeFetch.get&lt;User[]&gt;('\/users');       if (!result.ok) throw result.error; \/\/ \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0430       return result.data;     },     retry: false \/\/ \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u044b\u0442\u044c   }); }  function useCreateUser() {   return useMutation({     mutationFn: async (data: NewUser) =&gt; {       const result = await safeFetch.post&lt;User&gt;('\/users', data);       if (!result.ok) throw result.error; \/\/ \u043e\u043f\u044f\u0442\u044c       return result.data;     }   }); } <\/code><\/pre>\n<h4>\u0422\u0435\u043f\u0435\u0440\u044c: \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0440\u0435\u0448\u0430\u044e\u0442 \u0432\u0441\u0435<\/h4>\n<pre><code class=\"typescript\">const api = createSafeFetch({ baseURL: '\/api' }); const queryFn = createQueryFn(api); const mutationFn = createMutationFn(api);  function useUsers() {   return useQuery({     queryKey: ['users'],     queryFn: queryFn&lt;User[]&gt;('\/users'),     ...rqDefaults()   }); }  function useCreateUser() {   return useMutation({     mutationFn: mutationFn&lt;User&gt;('\/users', { method: 'POST' })   }); } <\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/strong>: 45 \u0441\u0442\u0440\u043e\u043a unwrap \u043a\u043e\u0434\u0430 \u2192 0 \u0441\u0442\u0440\u043e\u043a. \u0412\u0440\u0435\u043c\u044f \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430: 20 \u043c\u0438\u043d\u0443\u0442.<\/p>\n<h3>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0438\u0437 production<\/h3>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0411\u044b\u043b\u043e 15 \u0445\u0443\u043a\u043e\u0432 \u0441 React Query, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c unwrap \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c.<\/p>\n<p><strong>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0434\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430:<\/strong><\/p>\n<ul>\n<li>\n<p>8 \u0440\u0430\u0437 \u0437\u0430\u0431\u044b\u043b <code>retry: false<\/code> \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u043b \u0434\u0432\u043e\u0439\u043d\u044b\u0435 \u0440\u0435\u0442\u0440\u0430\u0438<\/p>\n<\/li>\n<li>\n<p>3 \u0440\u0430\u0437\u0430 TypeScript \u043d\u0435 \u043f\u043e\u0439\u043c\u0430\u043b \u043e\u0448\u0438\u0431\u043a\u0443 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>45 \u0441\u0442\u0440\u043e\u043a \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041f\u043e\u0441\u043b\u0435 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f:<\/strong><\/p>\n<ul>\n<li>\n<p>0 \u0437\u0430\u0431\u044b\u0442\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u2014 <code>rqDefaults()<\/code> \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u043d\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u2014 \u0435\u0434\u0438\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0438\u0441\u0442\u0438\u043d\u044b<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430<\/h3>\n<p>Safe-fetch \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430. \u042d\u0442\u043e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e HTTP:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0421\u0442\u0430\u0442\u0443\u0441<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"\/users\/asouei\" rel=\"noopener noreferrer nofollow\"><strong>@asouei<\/strong><\/a><strong>\/safe-fetch<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0 (stable)<\/p>\n<\/td>\n<td>\n<p align=\"left\">Core \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"\/users\/asouei\" rel=\"noopener noreferrer nofollow\"><strong>@asouei<\/strong><\/a><strong>\/safe-fetch-react-query<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">0.1 (experimental)<\/p>\n<\/td>\n<td>\n<p align=\"left\">React Query \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"\/users\/asouei\" rel=\"noopener noreferrer nofollow\"><strong>@asouei<\/strong><\/a><strong>\/safe-fetch-swr<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">Planned soon 2025<\/p>\n<\/td>\n<td>\n<p align=\"left\">SWR \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"\/users\/asouei\" rel=\"noopener noreferrer nofollow\"><strong>@asouei<\/strong><\/a><strong>\/eslint-plugin-safe-fetch<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">Planned soon 2025<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041b\u0438\u043d\u0442\u0438\u043d\u0433 \u043f\u0440\u0430\u0432\u0438\u043b\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4>\u041f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/h4>\n<ol>\n<li>\n<p><strong>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong>: \u043a\u0430\u0436\u0434\u044b\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c<\/strong>: TypeScript first \u0432\u043e \u0432\u0441\u0435\u043c<\/p>\n<\/li>\n<li>\n<p><strong>Zero config<\/strong>: \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u0441 \u0443\u043c\u043d\u044b\u043c\u0438 \u0434\u0435\u0444\u043e\u043b\u0442\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c<\/strong>: \u0430\u043f\u0434\u0435\u0439\u0442\u044b \u043d\u0435 \u043b\u043e\u043c\u0430\u044e\u0442 \u043a\u043e\u0434<\/p>\n<\/li>\n<\/ol>\n<h3>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u0430\u043c\u0438<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439<\/p>\n<\/th>\n<th>\n<p align=\"left\">safe-fetch ecosystem<\/p>\n<\/th>\n<th>\n<p align=\"left\">axios + react-query<\/p>\n<\/th>\n<th>\n<p align=\"left\">ky + react-query<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705 \u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043e<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705 \u0412 React Query \u0442\u043e\u0436\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u041d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u041d\u0435\u0442<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041e\u0431\u0449\u0438\u0439 \u0442\u0430\u0439\u043c\u0430\u0443\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705 totalTimeoutMs<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0422\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0422\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>Retry-After \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705 \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0412\u0440\u0443\u0447\u043d\u0443\u044e<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0412\u0440\u0443\u0447\u043d\u0443\u044e<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>Unwrap boilerplate<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705 \u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u0440\u0435\u0448\u0430\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0445\u0443\u043a\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0445\u0443\u043a\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>Bundle size<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">~3kb + ~0.5kb<\/p>\n<\/td>\n<td>\n<p align=\"left\">~13kb<\/p>\n<\/td>\n<td>\n<p align=\"left\">~11kb<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>Quick start \u0441 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439<\/h3>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h4>\n<pre><code class=\"bash\">npm install @asouei\/safe-fetch @asouei\/safe-fetch-react-query <\/code><\/pre>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 API<\/h4>\n<pre><code class=\"typescript\">import { createSafeFetch } from '@asouei\/safe-fetch'; import { createQueryFn, createMutationFn, rqDefaults } from '@asouei\/safe-fetch-react-query';  const api = createSafeFetch({   baseURL: '\/api',   timeoutMs: 5000,   retries: { retries: 2 } });  const queryFn = createQueryFn(api); const mutationFn = createMutationFn(api); <\/code><\/pre>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445<\/h4>\n<pre><code class=\"typescript\">function UserProfile({ userId }: { userId: string }) {   const { data: user, error, isLoading } = useQuery({     queryKey: ['user', userId],     queryFn: queryFn&lt;User&gt;(`\/users\/${userId}`),     ...rqDefaults()   });    const updateUser = useMutation({     mutationFn: mutationFn&lt;User&gt;(`\/users\/${userId}`, { method: 'PUT' })   });    if (isLoading) return &lt;div&gt;Loading...&lt;\/div&gt;;   if (error) {     \/\/ error typed as NetworkError | HttpError | TimeoutError | ValidationError     return &lt;div&gt;Error: {error.name} - {error.message}&lt;\/div&gt;;   }    return (     &lt;div&gt;       &lt;h1&gt;{user?.name}&lt;\/h1&gt;       &lt;button onClick={() =&gt; updateUser.mutate({ name: 'New Name' })}&gt;         Update       &lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<h3>Roadmap \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/h3>\n<h4>Stage 1 2025: \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0439<\/h4>\n<ul>\n<li>\n<p><strong>SWR \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/strong> \u2014 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e React Query (0.x experimental)<\/p>\n<\/li>\n<li>\n<p><strong>Next.js \u0441\u0442\u0430\u0440\u0442\u0435\u0440<\/strong> \u2014 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/p>\n<\/li>\n<li>\n<p><strong>Cloudflare Workers \u043f\u0440\u0438\u043c\u0435\u0440\u044b<\/strong> \u2014 \u0434\u043b\u044f edge computing<\/p>\n<\/li>\n<\/ul>\n<h4>Stage 2 2025: dev tools<\/h4>\n<ul>\n<li>\n<p><strong>ESLint plugin<\/strong> \u2014 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 <code>{ ok }<\/code><\/p>\n<\/li>\n<li>\n<p><strong>VS Code extension<\/strong> \u2014 \u0441\u043d\u0438\u043f\u043f\u0435\u0442\u044b \u0438 \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p><strong>Chrome DevTools<\/strong> \u2014 \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 safe-fetch \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<h4>Stage 3 2025: \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u0444\u0438\u0447\u0438<\/h4>\n<ul>\n<li>\n<p><strong>OpenAPI \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440<\/strong> \u2014 typed \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0438\u0437 \u0441\u0445\u0435\u043c<\/p>\n<\/li>\n<li>\n<p><strong>GraphQL \u043c\u043e\u0441\u0442<\/strong> \u2014 safe results \u0434\u043b\u044f GraphQL<\/p>\n<\/li>\n<li>\n<p><strong>Request deduplication<\/strong> \u2014 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<h3>\u041e\u0442\u0437\u044b\u0432\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430<\/h3>\n<p>\u0417\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043d\u044c \u0441\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0444\u0438\u0434\u0431\u0435\u043a:<\/p>\n<blockquote>\n<p>&#171;\u041d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 &#171;\u043f\u043e\u0442\u044b\u043a\u0430\u0442\u044c&#187;, \u0442\u0430\u043a \u043a\u0430\u043a \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 axios&#8217;\u0443 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.&#187; \u2014 \u0442\u0435\u0445\u043b\u0438\u0434 \u0438\u0437 e-commerce<\/p>\n<\/blockquote>\n<blockquote>\n<p>&#171;\u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043d\u0430 pet \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0445\u043e\u0447\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 fetch&#187; \u2014 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/p>\n<\/blockquote>\n<h3>\u0414\u043b\u044f \u043a\u043e\u0433\u043e \u044d\u0442\u0430 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430<\/h3>\n<h4>\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0430 React Query + TypeScript<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 TanStack React Query \u0438 \u0446\u0435\u043d\u0438\u0442\u0435 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u2014 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438.<\/p>\n<h4>\u041f\u0440\u043e\u0435\u043a\u0442\u044b \u0441 \u0436\u0435\u0441\u0442\u043a\u0438\u043c\u0438 SLA<\/h4>\n<p>\u041a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f safe-fetch (\u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0435 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b + \u0440\u0435\u0442\u0440\u0430\u0438) + React Query (\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435) = bulletproof \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430.<\/p>\n<h4>\u0420\u0430\u0441\u0442\u0443\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/h4>\n<p>\u0424\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442 HTTP \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435. \u0414\u0436\u0443\u043d\u0438\u043e\u0440\u044b \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435: \u043e\u0442 \u0438\u0434\u0435\u0438 \u0434\u043e \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/h3>\n<p>\u0417\u0430 72 \u0447\u0430\u0441\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><strong>1 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f<\/strong>: \u0438\u0434\u0435\u044f \u0438 \u0440\u0435\u043b\u0438\u0437 0.1.0<\/p>\n<\/li>\n<li>\n<p><strong>4 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f<\/strong>: \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0425\u0430\u0431\u0440\u0435, \u0444\u0438\u0434\u0431\u0435\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p><strong>5 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f<\/strong>: \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430 1.0 \u0441 React Query \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u043c<\/p>\n<\/li>\n<\/ul>\n<p><strong>Safe-fetch core 1.0<\/strong> \u0441\u0442\u0430\u0431\u0438\u043b\u0435\u043d \u0438 \u0433\u043e\u0442\u043e\u0432 \u043a production. <strong>React Query adapter 0.1<\/strong> \u2014 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u0443\u0436\u0435 \u0441\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0435\u0441\u044c unwrap-\u0431\u043e\u0439\u043b\u0435\u0440\u043f\u043b\u0435\u0439\u0442. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435, \u043a\u0438\u043d\u044c\u0442\u0435 \u0444\u0438\u0434\u0431\u0435\u043a \u0432 Issues \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0437\u0432\u0435\u0437\u0434\u0443 \u043d\u0430 GitHub \u2014 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0443 \u0440\u0430\u0441\u0442\u0438.<\/p>\n<p><strong>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<\/strong> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e SWR \u0430\u0434\u0430\u043f\u0442\u0435\u0440. \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044e \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<hr\/>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/asouei\/safe-fetch\" rel=\"noopener noreferrer nofollow\">GitHub \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/asouei\/safe-fetch\/tree\/master\/packages\/core\" rel=\"noopener noreferrer nofollow\">Core \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/asouei\/safe-fetch\/tree\/master\/packages\/react-query\" rel=\"noopener noreferrer nofollow\">React Query \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.npmjs.com\/package\/@asouei\/safe-fetch\" rel=\"noopener noreferrer nofollow\">NPM: @asouei\/safe-fetch<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.npmjs.com\/package\/@asouei\/safe-fetch-react-query\" rel=\"noopener noreferrer nofollow\">NPM: @asouei\/safe-fetch-react-query<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/944362\/\"> https:\/\/habr.com\/ru\/articles\/944362\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0422\u0440\u0438 \u0434\u043d\u044f \u043d\u0430\u0437\u0430\u0434 \u044f \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e safe-fetch \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0431\u0438\u0440\u0430\u0435\u0442 try\/catch \u0438\u0437 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412\u0447\u0435\u0440\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u0431\u0440\u0430\u043b\u0430 8,5K \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432 \u0438 64 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u043a\u043b\u0430\u0434\u043a\u0438. \u0410 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e safe-fetch 1.0 \u2014 \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0430 \u0446\u0435\u043b\u0443\u044e \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0443.<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/943732\/\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e<\/a><\/p>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0444\u0438\u0434\u0431\u0435\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0437\u0430 72 \u0447\u0430\u0441\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u043d\u0430\u0434 fetch \u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e HTTP.<\/p>\n<h3>\u041a\u0430\u043a \u0432\u0441\u0451 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c<\/h3>\n<p>1 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b safe-fetch 0.1.0 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u044e. \u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u0432\u043c\u0435\u0441\u0442\u043e try\/catch \u0432\u0435\u0437\u0434\u0435 \u2014 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438.<\/p>\n<pre><code class=\"typescript\">\/\/ \u0411\u044b\u043b\u043e try {   const res = await fetch('\/users');   if (!res.ok) throw new Error(`HTTP ${res.status}`);   const data = await res.json(); } catch (e) {   console.error('\u0427\u0442\u043e-\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c:', e.message); }  \/\/ \u0421\u0442\u0430\u043b\u043e const result = await safeFetch.get&lt;User[]&gt;('\/users'); if (result.ok) {   console.log(result.data); } else {   console.error(result.error.name); \/\/ NetworkError | TimeoutError | HttpError } <\/code><\/pre>\n<p>4 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u044b\u0448\u043b\u0430 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435. 5 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f \u2014 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u2014 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u044e 1.0 \u0441 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439.<\/p>\n<h3>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0437\u0430 \u0442\u0440\u0438 \u0434\u043d\u044f<\/h3>\n<h4>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0432\u0437\u043e\u0440\u0432\u0430\u043b\u0430\u0441\u044c<\/h4>\n<ul>\n<li>\n<p><strong>8,5K \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432<\/strong> \u0437\u0430 \u043f\u0435\u0440\u0432\u044b\u0435 \u0441\u0443\u0442\u043a\u0438<\/p>\n<\/li>\n<li>\n<p><strong>64 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u043a\u043b\u0430\u0434\u043a\u0438<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>30 \u0437\u0432\u0435\u0437\u0434<\/strong> \u043d\u0430 GitHub<\/p>\n<\/li>\n<li>\n<p><strong>70 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0439<\/strong> \u0441 NPM<\/p>\n<\/li>\n<li>\n<p><strong>2 \u043f\u0443\u043b\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442\u0430<\/strong> \u043e\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u0432 <strong>Awesome TypeScript<\/strong><\/p>\n<\/li>\n<\/ul>\n<h4>\u0424\u0438\u0434\u0431\u0435\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0431\u044b\u043b\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>&#171;\u041a\u0430\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 React Query?&#187;<\/p>\n<\/li>\n<li>\n<p>&#171;\u0410 \u0434\u043b\u044f SWR \u0431\u0443\u0434\u0435\u0442?&#187;<\/p>\n<\/li>\n<li>\n<p>&#171;\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u044d\u0442\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u043d\u043e\u0440\u0435\u043f\u043e?&#187;<\/p>\n<\/li>\n<li>\n<p>&#171;\u041d\u0443\u0436\u0435\u043d ESLint plugin \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 { ok }&#187;<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e: \u043e\u0434\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u041d\u0443\u0436\u043d\u0430 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430.<\/p>\n<h3>Safe-fetch 1.0: \u0441\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u2014 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044e 1.0.0. \u041d\u0435 \u043d\u043e\u0432\u044b\u0435 \u0444\u0438\u0447\u0438, \u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b:<\/p>\n<h4>\u041c\u043e\u043d\u043e\u0440\u0435\u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h4>\n<p>\u041f\u0435\u0440\u0435\u0435\u0437\u0434 \u0432 workspace \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438:<\/p>\n<pre><code>packages\/ \u251c\u2500\u2500 core\/                 # @asouei\/safe-fetch   \u2514\u2500\u2500 react-query\/          # @asouei\/safe-fetch-react-query <\/code><\/pre>\n<h4>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u0435\u043a<\/h4>\n<ul>\n<li>\n<p><strong>Vite + Vitest<\/strong> \u0432\u043c\u0435\u0441\u0442\u043e custom build<\/p>\n<\/li>\n<li>\n<p><strong>GitHub Actions<\/strong> \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0441\u0440\u0430\u0437\u0443<\/p>\n<\/li>\n<li>\n<p><strong>ESM\/CJS<\/strong> \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u044b \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u044b<\/p>\n<\/li>\n<\/ul>\n<h4>Zero breaking changes<\/h4>\n<p>\u0412\u0435\u0441\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"typescript\">const result = await safeFetch.get('\/api\/data'); \/\/ \u0422\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0432 0.1.0 <\/code><\/pre>\n<h3>\u041d\u043e\u0432\u0438\u043d\u043a\u0430: React Query \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/h3>\n<p>\u0421\u0430\u043c\u044b\u0439 \u0447\u0430\u0441\u0442\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043a\u0430\u0441\u0430\u043b\u0441\u044f React Query. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u0430: React Query \u043e\u0436\u0438\u0434\u0430\u0435\u0442 throws, safe-fetch \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>{ ok: false }<\/code>.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445<\/h4>\n<p>\u0412 React Query \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0431\u0440\u043e\u0441\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u043b\u044f \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438:<\/p>\n<pre><code class=\"typescript\">const { data, error } = useQuery({   queryFn: async () =&gt; {     const response = await fetch('\/users');     if (!response.ok) throw new Error('Failed');     return response.json();   } }); <\/code><\/pre>\n<p>\u0421 safe-fetch \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0434\u0435\u043b\u0430\u0442\u044c unwrap \u0432\u0440\u0443\u0447\u043d\u0443\u044e:<\/p>\n<pre><code class=\"typescript\">const { data, error } = useQuery({   queryFn: async () =&gt; {     const result = await safeFetch.get&lt;User[]&gt;('\/users');     if (!result.ok) throw result.error; \/\/ \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u0440\u0443\u0447\u043d\u0443\u044e     return result.data;   },   retry: false \/\/ \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c }); <\/code><\/pre>\n<h4>\u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/h4>\n<p>\u0412\u0441\u0442\u0440\u0435\u0447\u0430\u0439\u0442\u0435 <code>@asouei\/safe-fetch-react-query@0.1.0<\/code>:<\/p>\n<pre><code class=\"bash\">npm install @asouei\/safe-fetch-react-query <\/code><\/pre>\n<pre><code class=\"typescript\">import { createQueryFn, rqDefaults } from '@asouei\/safe-fetch-react-query';  const queryFn = createQueryFn(api);  const { data, error } = useQuery({   queryKey: ['users'],   queryFn: queryFn&lt;User[]&gt;('\/users'),   ...rqDefaults() \/\/ { retry: false } + \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 });  \/\/ error \u0442\u0435\u043f\u0435\u0440\u044c typed: NetworkError | HttpError | TimeoutError | ValidationError <\/code><\/pre>\n<h4>\u0427\u0442\u043e \u0434\u0430\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/h4>\n<ol>\n<li>\n<p><strong>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 unwrap<\/strong>: <code>{ ok: false }<\/code> \u2192 <code>throw error<\/code><\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438<\/strong>: TypeScript \u0437\u043d\u0430\u0435\u0442 \u0442\u0438\u043f \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 React Query<\/p>\n<\/li>\n<li>\n<p><strong>\u0424\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/strong>: <code>createQueryFn<\/code>, <code>createMutationFn<\/code><\/p>\n<\/li>\n<li>\n<p><strong>\u0423\u043c\u043d\u044b\u0435 \u0434\u0435\u0444\u043e\u043b\u0442\u044b<\/strong>: <code>rqDefaults()<\/code> \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0442\u0440\u0430\u0438<\/p>\n<\/li>\n<\/ol>\n<h3>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435<\/h3>\n<h4>\u0420\u0430\u043d\u044c\u0448\u0435: boilerplate \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0445\u0443\u043a\u0435<\/h4>\n<pre><code class=\"typescript\">function useUsers() {   return useQuery({     queryKey: ['users'],     queryFn: async () =&gt; {       const result = await safeFetch.get&lt;User[]&gt;('\/users');       if (!result.ok) throw result.error; \/\/ \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0430       return result.data;     },     retry: false \/\/ \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u044b\u0442\u044c   }); }  function useCreateUser() {   return useMutation({     mutationFn: async (data: NewUser) =&gt; {       const result = await safeFetch.post&lt;User&gt;('\/users', data);       if (!result.ok) throw result.error; \/\/ \u043e\u043f\u044f\u0442\u044c       return result.data;     }   }); } <\/code><\/pre>\n<h4>\u0422\u0435\u043f\u0435\u0440\u044c: \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0440\u0435\u0448\u0430\u044e\u0442 \u0432\u0441\u0435<\/h4>\n<pre><code class=\"typescript\">const api = createSafeFetch({ baseURL: '\/api' }); const queryFn = createQueryFn(api); const mutationFn = createMutationFn(api);  function useUsers() {   return useQuery({     queryKey: ['users'],     queryFn: queryFn&lt;User[]&gt;('\/users'),     ...rqDefaults()   }); }  function useCreateUser() {   return useMutation({     mutationFn: mutationFn&lt;User&gt;('\/users', { method: 'POST' })   }); } <\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/strong>: 45 \u0441\u0442\u0440\u043e\u043a unwrap \u043a\u043e\u0434\u0430 \u2192 0 \u0441\u0442\u0440\u043e\u043a. \u0412\u0440\u0435\u043c\u044f \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430: 20 \u043c\u0438\u043d\u0443\u0442.<\/p>\n<h3>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0438\u0437 production<\/h3>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0411\u044b\u043b\u043e 15 \u0445\u0443\u043a\u043e\u0432 \u0441 React Query, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c unwrap \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c.<\/p>\n<p><strong>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0434\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430:<\/strong><\/p>\n<ul>\n<li>\n<p>8 \u0440\u0430\u0437 \u0437\u0430\u0431\u044b\u043b <code>retry: false<\/code> \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u043b \u0434\u0432\u043e\u0439\u043d\u044b\u0435 \u0440\u0435\u0442\u0440\u0430\u0438<\/p>\n<\/li>\n<li>\n<p>3 \u0440\u0430\u0437\u0430 TypeScript \u043d\u0435 \u043f\u043e\u0439\u043c\u0430\u043b \u043e\u0448\u0438\u0431\u043a\u0443 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>45 \u0441\u0442\u0440\u043e\u043a \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041f\u043e\u0441\u043b\u0435 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f:<\/strong><\/p>\n<ul>\n<li>\n<p>0 \u0437\u0430\u0431\u044b\u0442\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u2014 <code>rqDefaults()<\/code> \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u043d\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u2014 \u0435\u0434\u0438\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0438\u0441\u0442\u0438\u043d\u044b<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430<\/h3>\n<p>Safe-fetch \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430. \u042d\u0442\u043e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e HTTP:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0421\u0442\u0430\u0442\u0443\u0441<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"\/users\/asouei\" rel=\"noopener noreferrer nofollow\"><strong>@asouei<\/strong><\/a><strong>\/safe-fetch<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0 (stable)<\/p>\n<\/td>\n<td>\n<p align=\"left\">Core \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"\/users\/asouei\" rel=\"noopener noreferrer nofollow\"><strong>@asouei<\/strong><\/a><strong>\/safe-fetch-react-query<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">0.1 (experimental)<\/p>\n<\/td>\n<td>\n<p align=\"left\">React Query \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"\/users\/asouei\" rel=\"noopener noreferrer nofollow\"><strong>@asouei<\/strong><\/a><strong>\/safe-fetch-swr<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">Planned soon 2025<\/p>\n<\/td>\n<td>\n<p align=\"left\">SWR \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"\/users\/asouei\" rel=\"noopener noreferrer nofollow\"><strong>@asouei<\/strong><\/a><strong>\/eslint-plugin-safe-fetch<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">Planned soon 2025<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041b\u0438\u043d\u0442\u0438\u043d\u0433 \u043f\u0440\u0430\u0432\u0438\u043b\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4>\u041f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/h4>\n<ol>\n<li>\n<p><strong>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong>: \u043a\u0430\u0436\u0434\u044b\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c<\/strong>: TypeScript first \u0432\u043e \u0432\u0441\u0435\u043c<\/p>\n<\/li>\n<li>\n<p><strong>Zero config<\/strong>: \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u0441 \u0443\u043c\u043d\u044b\u043c\u0438 \u0434\u0435\u0444\u043e\u043b\u0442\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c<\/strong>: \u0430\u043f\u0434\u0435\u0439\u0442\u044b \u043d\u0435 \u043b\u043e\u043c\u0430\u044e\u0442 \u043a\u043e\u0434<\/p>\n<\/li>\n<\/ol>\n<h3>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u0430\u043c\u0438<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439<\/p>\n<\/th>\n<th>\n<p align=\"left\">safe-fetch ecosystem<\/p>\n<\/th>\n<th>\n<p align=\"left\">axios + react-query<\/p>\n<\/th>\n<th>\n<p align=\"left\">ky + react-query<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705 \u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043e<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705 \u0412 React Query \u0442\u043e\u0436\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u041d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u041d\u0435\u0442<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041e\u0431\u0449\u0438\u0439 \u0442\u0430\u0439\u043c\u0430\u0443\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705 totalTimeoutMs<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0422\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0422\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>Retry-After \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705 \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0412\u0440\u0443\u0447\u043d\u0443\u044e<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0412\u0440\u0443\u0447\u043d\u0443\u044e<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>Unwrap boilerplate<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705 \u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u0440\u0435\u0448\u0430\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0445\u0443\u043a\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0445\u0443\u043a\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>Bundle size<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">~3kb + ~0.5kb<\/p>\n<\/td>\n<td>\n<p align=\"left\">~13kb<\/p>\n<\/td>\n<td>\n<p align=\"left\">~11kb<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>Quick start \u0441 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439<\/h3>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h4>\n<pre><code class=\"bash\">npm install @asouei\/safe-fetch @asouei\/safe-fetch-react-query <\/code><\/pre>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 API<\/h4>\n<pre><code class=\"typescript\">import { createSafeFetch } from '@asouei\/safe-fetch'; import { createQueryFn, createMutationFn, rqDefaults } from '@asouei\/safe-fetch-react-query';  const api = createSafeFetch({   baseURL: '\/api',   timeoutMs: 5000,   retries: { retries: 2 } });  const queryFn = createQueryFn(api); const mutationFn = createMutationFn(api); <\/code><\/pre>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445<\/h4>\n<pre><code class=\"typescript\">function UserProfile({ userId }: { userId: string }) {   const { data: user, error, isLoading } = useQuery({     queryKey: ['user', userId],     queryFn: queryFn&lt;User&gt;(`\/users\/${userId}`),     ...rqDefaults()   });    const updateUser = useMutation({     mutationFn: mutationFn&lt;User&gt;(`\/users\/${userId}`, { method: 'PUT' })   });    if (isLoading) return &lt;div&gt;Loading...&lt;\/div&gt;;   if (error) {     \/\/ error typed as NetworkError | HttpError | TimeoutError | ValidationError     return &lt;div&gt;Error: {error.name} - {error.message}&lt;\/div&gt;;   }    return (     &lt;div&gt;       &lt;h1&gt;{user?.name}&lt;\/h1&gt;       &lt;button onClick={() =&gt; updateUser.mutate({ name: 'New Name' })}&gt;         Update       &lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<h3>Roadmap \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/h3>\n<h4>Stage 1 2025: \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0439<\/h4>\n<ul>\n<li>\n<p><strong>SWR \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/strong> \u2014 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e React Query (0.x experimental)<\/p>\n<\/li>\n<li>\n<p><strong>Next.js \u0441\u0442\u0430\u0440\u0442\u0435\u0440<\/strong> \u2014 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/p>\n<\/li>\n<li>\n<p><strong>Cloudflare Workers \u043f\u0440\u0438\u043c\u0435\u0440\u044b<\/strong> \u2014 \u0434\u043b\u044f edge computing<\/p>\n<\/li>\n<\/ul>\n<h4>Stage 2 2025: dev tools<\/h4>\n<ul>\n<li>\n<p><strong>ESLint plugin<\/strong> \u2014 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 <code>{ ok }<\/code><\/p>\n<\/li>\n<li>\n<p><strong>VS Code extension<\/strong> \u2014 \u0441\u043d\u0438\u043f\u043f\u0435\u0442\u044b \u0438 \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p><strong>Chrome DevTools<\/strong> \u2014 \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 safe-fetch \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<h4>Stage 3 2025: \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u0444\u0438\u0447\u0438<\/h4>\n<ul>\n<li>\n<p><strong>OpenAPI \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440<\/strong> \u2014 typed \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0438\u0437 \u0441\u0445\u0435\u043c<\/p>\n<\/li>\n<li>\n<p><strong>GraphQL \u043c\u043e\u0441\u0442<\/strong> \u2014 safe results \u0434\u043b\u044f GraphQL<\/p>\n<\/li>\n<li>\n<p><strong>Request deduplication<\/strong> \u2014 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<h3>\u041e\u0442\u0437\u044b\u0432\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430<\/h3>\n<p>\u0417\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043d\u044c \u0441\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0444\u0438\u0434\u0431\u0435\u043a:<\/p>\n<blockquote>\n<p>&#171;\u041d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 &#171;\u043f\u043e\u0442\u044b\u043a\u0430\u0442\u044c&#187;, \u0442\u0430\u043a \u043a\u0430\u043a \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 axios&#8217;\u0443 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.&#187; \u2014 \u0442\u0435\u0445\u043b\u0438\u0434 \u0438\u0437 e-commerce<\/p>\n<\/blockquote>\n<blockquote>\n<p>&#171;\u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043d\u0430 pet \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0445\u043e\u0447\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 fetch&#187; \u2014 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/p>\n<\/blockquote>\n<h3>\u0414\u043b\u044f \u043a\u043e\u0433\u043e \u044d\u0442\u0430 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430<\/h3>\n<h4>\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0430 React Query + TypeScript<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 TanStack React Query \u0438 \u0446\u0435\u043d\u0438\u0442\u0435 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u2014 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438.<\/p>\n<h4>\u041f\u0440\u043e\u0435\u043a\u0442\u044b \u0441 \u0436\u0435\u0441\u0442\u043a\u0438\u043c\u0438 SLA<\/h4>\n<p>\u041a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f safe-fetch (\u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0435 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b + \u0440\u0435\u0442\u0440\u0430\u0438) + React Query (\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435) = bulletproof \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430.<\/p>\n<h4>\u0420\u0430\u0441\u0442\u0443\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/h4>\n<p>\u0424\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442 HTTP \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435. \u0414\u0436\u0443\u043d\u0438\u043e\u0440\u044b \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435: \u043e\u0442 \u0438\u0434\u0435\u0438 \u0434\u043e \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/h3>\n<p>\u0417\u0430 72 \u0447\u0430\u0441\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><strong>1 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f<\/strong>: \u0438\u0434\u0435\u044f \u0438 \u0440\u0435\u043b\u0438\u0437 0.1.0<\/p>\n<\/li>\n<li>\n<p><strong>4 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f<\/strong>: \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0425\u0430\u0431\u0440\u0435, \u0444\u0438\u0434\u0431\u0435\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p><strong>5 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f<\/strong>: \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430 1.0 \u0441 React Query \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u043c<\/p>\n<\/li>\n<\/ul>\n<p><strong>Safe-fetch core 1.0<\/strong> \u0441\u0442\u0430\u0431\u0438\u043b\u0435\u043d \u0438 \u0433\u043e\u0442\u043e\u0432 \u043a production. <strong>React Query adapter 0.1<\/strong> \u2014 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u0443\u0436\u0435 \u0441\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0435\u0441\u044c unwrap-\u0431\u043e\u0439\u043b\u0435\u0440\u043f\u043b\u0435\u0439\u0442. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435, \u043a\u0438\u043d\u044c\u0442\u0435 \u0444\u0438\u0434\u0431\u0435\u043a \u0432 Issues \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0437\u0432\u0435\u0437\u0434\u0443 \u043d\u0430 GitHub \u2014 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0443 \u0440\u0430\u0441\u0442\u0438.<\/p>\n<p><strong>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<\/strong> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e SWR \u0430\u0434\u0430\u043f\u0442\u0435\u0440. \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044e \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<hr\/>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/asouei\/safe-fetch\" rel=\"noopener noreferrer nofollow\">GitHub \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/asouei\/safe-fetch\/tree\/master\/packages\/core\" rel=\"noopener noreferrer nofollow\">Core \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/asouei\/safe-fetch\/tree\/master\/packages\/react-query\" rel=\"noopener noreferrer nofollow\">React Query \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.npmjs.com\/package\/@asouei\/safe-fetch\" rel=\"noopener noreferrer nofollow\">NPM: @asouei\/safe-fetch<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.npmjs.com\/package\/@asouei\/safe-fetch-react-query\" rel=\"noopener noreferrer nofollow\">NPM: @asouei\/safe-fetch-react-query<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/944362\/\"> https:\/\/habr.com\/ru\/articles\/944362\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-474073","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/474073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=474073"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/474073\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=474073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=474073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=474073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}