{"id":47564,"library":"fetch-absolute","title":"fetch-absolute","description":"Fetch wrapper that prepends a default base URL to all fetch calls. Version 1.0.0, released as a stable package. It works with both browser's native fetch and node-fetch. Simplifies testing and server-side code by avoiding repetitive URL prefixes. Unlike node-fetch or isomorphic-fetch, it adds a base URL layer without modifying the underlying fetch implementation.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/zurfyx/fetch-absolute","tags":["javascript","fetch","node-fetch","absolute","prefix","url","test"],"install":[{"cmd":"npm install fetch-absolute","lang":"bash","label":"npm"},{"cmd":"yarn add fetch-absolute","lang":"bash","label":"yarn"},{"cmd":"pnpm add fetch-absolute","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package exports a single default function; named import is incorrect.","wrong":"const { fetchAbsolute } = require('fetch-absolute');","symbol":"fetchAbsolute (default)","correct":"import fetchAbsolute from 'fetch-absolute';"},{"note":"CommonJS require returns the default export directly, no .default needed.","wrong":"const fetchAbsolute = require('fetch-absolute').default;","symbol":"require usage","correct":"const fetchAbsolute = require('fetch-absolute');"},{"note":"fetch-absolute requires a fetch function as the first argument; omitting it will cause a TypeError.","wrong":"const fetchApi = require('fetch-absolute')('http://localhost:3030');","symbol":"Usage with node-fetch","correct":"const fetch = require('node-fetch'); const fetchApi = require('fetch-absolute')(fetch)('http://localhost:3030');"}],"quickstart":{"code":"const fetch = require('node-fetch');\nconst fetchAbsolute = require('fetch-absolute');\n\nconst fetchApi = fetchAbsolute(fetch)('http://localhost:3030');\n\nasync function example() {\n  const response = await fetchApi('/api/data');\n  const data = await response.json();\n  console.log(data);\n}\n\nexample();","lang":"javascript","description":"Shows how to create an absolute-fetch wrapper using node-fetch and make a request."},"warnings":[{"fix":"Ensure all request paths start with '/' to have the base URL prepended.","message":"Requests not starting with '/' are treated as relative; absolute URLs in requests are not automatically prefixed.","severity":"gotcha","affected_versions":"<=1.0.0"},{"fix":"Manually ensure base URL ends with '/' if needed, or request path starts correctly.","message":"Does not handle pathname merging (e.g. ends with '/' or not); base URL and request path are concatenated directly.","severity":"gotcha","affected_versions":"<=1.0.0"}],"env_vars":null,"search_vec":"'1.0.0':17 'absolut':3,72 'add':56 'avoid':43 'base':10,58 'browser':27 'call':15 'code':41 'default':9 'fetch':2,4,14,30,34,50,54,65,68,71 'fetch-absolut':1 'implement':66 'isomorph':53 'isomorphic-fetch':52 'javascript':67 'layer':60 'modifi':62 'nativ':29 'node':33,49,70 'node-fetch':32,48,69 'packag':22 'prefix':46,73 'prepend':7 'releas':18 'repetit':44 'server':39 'server-sid':38 'side':40 'simplifi':35 'stabl':21 'test':36,75 'under':64 'unlik':47 'url':11,45,59,74 'version':16 'without':61 'work':24 'wrapper':5","created_at":"2026-06-07T16:52:09.777518+00:00","updated_at":"2026-06-07T16:52:09.777518+00:00","problems":[{"fix":"Ensure you pass a valid fetch function: const fetchAbsolute = require('fetch-absolute'); const fetch = require('node-fetch'); const fetchApi = fetchAbsolute(fetch)('http://localhost:3030');","cause":"Missing or invalid fetch argument passed to fetchAbsolute.","error":"TypeError: fetch is not a function"},{"fix":"Prefix your request path with '/': fetchApi('/api/endpoint')","cause":"Request path doesn't start with '/' and is not an absolute URL.","error":"Error: Only absolute URLs are allowed"}],"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/zurfyx/fetch-absolute#readme","github":"https://github.com/zurfyx/fetch-absolute","docs":null,"changelog":null,"pypi":null,"npm":"fetch-absolute","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"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}}