{"id":47652,"library":"fetch-service-parser","title":"fetch-service-parser","description":"A lightweight HTTP client built on the Fetch API with whatwg-fetch polyfill. It simplifies defining RESTful endpoints with support for path parameters, file uploads, custom headers (JSON, Form URL-encoded), request queuing, mock data, response parsing, parameter validation, and global error events. Version 0.2.16. Low release cadence. Ships TypeScript types. Differentiators: integrated mocking, useQueue option for sequential requests, and built-in content type constants. Suitable for React and Node environments.","status":"active","version":"0.2.16","language":"javascript","source_language":"en","source_url":"https://github.com/longZ/fetch-service","tags":["javascript","typescript"],"install":[{"cmd":"npm install fetch-service-parser","lang":"bash","label":"npm"},{"cmd":"yarn add fetch-service-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add fetch-service-parser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used as polyfill for fetch API in environments where fetch is not available (e.g., older browsers, Node.js < 18)","package":"whatwg-fetch","optional":true}],"imports":[{"note":"Named export, not default. Contains parseRequest and event methods.","wrong":"import services from 'fetch-service-parser'","symbol":"services","correct":"import { services } from 'fetch-service-parser'"},{"note":"parseRequest is a property of the services object, not a direct export.","wrong":"import { parseRequest } from 'fetch-service-parser'","symbol":"parseRequest","correct":"import { services } from 'fetch-service-parser'; const { parseRequest } = services"},{"note":"Named export with uppercase keys: JSON, FORM_URL, etc.","wrong":"import { contentTypes } from 'fetch-service-parser'","symbol":"CONTENT_TYPES","correct":"import { CONTENT_TYPES } from 'fetch-service-parser'"}],"quickstart":{"code":"// api.js\nimport { services, CONTENT_TYPES } from 'fetch-service-parser';\nconst { parseRequest } = services;\n\nexport const List = parseRequest({\n  url: '/api/list',\n});\n\nexport const Create = parseRequest({\n  url: '/api/create',\n  method: 'POST',\n  headers: {\n    'Content-Type': CONTENT_TYPES.FORM_URL,\n  },\n});\n\n// usage.js\nimport { List } from './api.js';\n\nList({ pageIndex: 1, pageSize: 10 })\n  .then(items => console.log(items))\n  .catch(err => console.error(err));","lang":"typescript","description":"Shows defining two endpoints using parseRequest, configuring method and headers with CONTENT_TYPES, then calling List with query params."},"warnings":[{"fix":"Use: import { services } from 'fetch-service-parser'; const { parseRequest } = services;","message":"parseRequest is not directly exported; it must be accessed via services.parseRequest","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure the export is used as a function call (List(params)) not as JSX element.","message":"Exporting List as arrow function with parseRequest may cause tree-shaking issues if named export is mistaken for a React component","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"To completely ignore errors, do not attach an 'error' listener, or filter errors inside the listener.","message":"Error event 'error' is global and noErrorTip does not prevent the event from being emitted; it only suppresses UI alerts","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set debug: true in the configuration or pass it in parseRequest options.","message":"The mock option only works when debug is true; it's easy to forget setting debug: true","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.2.16':51 'api':13 'built':9,68 'built-in':67 'cadenc':54 'client':8 'constant':72 'content':70 'custom':31 'data':41 'defin':21 'differenti':58 'encod':37 'endpoint':23 'environ':78 'error':48 'event':49 'fetch':2,12,17 'fetch-service-pars':1 'file':29 'form':34 'global':47 'header':32 'http':7 'integr':59 'javascript':79 'json':33 'lightweight':6 'low':52 'mock':40,60 'node':77 'option':62 'paramet':28,44 'pars':43 'parser':4 'path':27 'polyfil':18 'queu':39 'react':75 'releas':53 'request':38,65 'respons':42 'rest':22 'sequenti':64 'servic':3 'ship':55 'simplifi':20 'suitabl':73 'support':25 'type':57,71 'typescript':56,80 'upload':30 'url':36 'url-encod':35 'usequeu':61 'valid':45 'version':50 'whatwg':16 'whatwg-fetch':15","created_at":"2026-06-07T16:52:36.427400+00:00","updated_at":"2026-06-07T16:52:36.427400+00:00","problems":[{"fix":"Use: import { services } from 'fetch-service-parser';","cause":"importing services incorrectly (default import instead of named import)","error":"TypeError: services.parseRequest is not a function"},{"fix":"Install and import whatwg-fetch before using fetch-service-parser: import 'whatwg-fetch'; or add polyfill to entry point.","cause":"whatwg-fetch polyfill not loaded when running in environments without native fetch (e.g., Node < 18, IE)","error":"Uncaught (in promise) TypeError: Failed to fetch"},{"fix":"Add debug: true to the parseRequest configuration: parseRequest({ url: '...', mock: {...}, debug: true })","cause":"debug option not set to true","error":"Mock data was not used even though mock option was provided"},{"fix":"Import CONTENT_TYPES correctly: import { CONTENT_TYPES } from 'fetch-service-parser'; and use like CONTENT_TYPES.FORM_URL","cause":"Using CONTENT_TYPES constant incorrectly (e.g., lowercased or wrong import)","error":"Content-Type header was not applied as expected"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/longZ/fetch-service#readme","github":"https://github.com/longZ/fetch-service","docs":null,"changelog":null,"pypi":null,"npm":"fetch-service-parser","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}