{"id":47193,"library":"bs-fetch","title":"bs-fetch","description":"Low-level OCaml/ReasonML bindings to the Fetch API for BuckleScript (Belt/bs-platform). Current stable version is 0.6.2, last released in 2019. The package provides thin, type-safe bindings to fetch, Response, Headers, Request, AbortController, and FormData. It targets BuckleScript 5+ and is intended as a foundation for higher-level libraries. Unlike many other fetch bindings, it follows the ML naming conventions (e.g., `Response.type_` instead of `Response._type`) and requires a polyfill in Node.js. The package is no longer actively maintained; users should consider migrating to newer solutions like `promise-fetch` or direct `Js.Promise` + `fetch`.","status":"maintenance","version":"0.6.2","language":"javascript","source_language":"en","source_url":"https://github.com/reasonml-community/bs-fetch","tags":["javascript","fetch","browser","xhr","bucklescript"],"install":[{"cmd":"npm install bs-fetch","lang":"bash","label":"npm"},{"cmd":"yarn add bs-fetch","lang":"bash","label":"yarn"},{"cmd":"pnpm add bs-fetch","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as a polyfill for Node.js since fetch is a Web API not available natively in Node.","package":"isomorphic-fetch","optional":true},{"reason":"Required as a peer dependency; the bindings rely on BuckleScript/bs-platform's Js module.","package":"bs-platform","optional":false}],"imports":[{"note":"Bs_fetch is deprecated since 0.2.0, use Fetch module instead.","wrong":"let fetch = Bs_fetch.fetch;","symbol":"fetch","correct":"let fetch = Fetch.fetch;"},{"note":"Use the Fetch module; Bs_fetch is deprecated.","wrong":"let response = Bs_fetch.Response.make();","symbol":"Response","correct":"open Fetch;\nlet response = Response.make();"},{"note":"Headers.makeWithDict is available but make() with array pairs is more common in OCaml.","wrong":"let headers = Fetch.Headers.makeWithDict(Js.Dict.fromList([(\"Content-Type\", \"application/json\")]));","symbol":"Headers","correct":"open Fetch;\nlet headers = Headers.make();"},{"note":"FormData was added in 0.6.2 and does not have a makeWithDict variant.","wrong":"let formData = Fetch.FormData.makeWithDict(...);","symbol":"FormData","correct":"open Fetch;\nlet formData = FormData.make();"}],"quickstart":{"code":"// Install: npm install bs-fetch\n// bsconfig.json: \"bs-dependencies\": [\"bs-fetch\"]\n\n// In your ReasonML file:\nlet fetchJson = (url: string) => {\n  open Fetch;\n  Js.Promise.(\n    Fetch.fetch(url)\n    |> then_(Response.json)\n    |> then_(json => {\n         Js.log(json);\n         resolve(json);\n       })\n    |> catch(err => {\n         Js.log2(\"Fetch failed\", err);\n         resolve(Js.Json.Null);\n       })\n  );\n};\n\n// For Node.js, add at top entry file:\n[%raw \"require('isomorphic-fetch')\"];","lang":"javascript","description":"Shows how to use bs-fetch to perform a GET request and parse JSON response, including error handling and Node polyfill setup."},"warnings":[{"fix":"Replace all uses of `Response._type` with `Response.type_`.","message":"In 0.6.0, Response._type was renamed to Response.type_ to follow name mangling conventions.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Change `Bs_fetch.xxx` to `Fetch.xxx`.","message":"The module Bs_fetch is deprecated since 0.2.0. Use Fetch instead.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Ensure code that used the return values of these functions is updated.","message":"In 0.5.0, Headers.append and Headers.delete now return unit instead of being void.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Install isomorphic-fetch and add `[%raw \"require('isomorphic-fetch')\"]` at the top of your entry file.","message":"Fetch API is not available in Node.js by default. You must provide a polyfill like isomorphic-fetch.","severity":"gotcha","affected_versions":"all"},{"fix":"Use Headers.make([(\"key\", \"value\")]) or Headers.makeWithDict(Js.Dict.fromList(...)) accordingly.","message":"Headers.makeWithDict is available only for OCaml users; ReasonML users may prefer Headers.make with array pairs.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Consider migrating to newer libraries like promise-fetch or directly using Js.Promise with the global fetch binding.","message":"The package is no longer actively maintained. Last release was 2019.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.6.2':20 '2019':24 '5':44 'abortcontrol':38 'activ':83 'api':12 'belt/bs-platform':15 'bind':8,32,60 'browser':102 'bs':2 'bs-fetch':1 'bucklescript':14,43,104 'consid':87 'convent':66 'current':16 'direct':97 'e.g':67 'fetch':3,11,34,59,95,99,101 'follow':62 'formdata':40 'foundat':50 'header':36 'higher':53 'higher-level':52 'instead':69 'intend':47 'javascript':100 'js.promise':98 'last':21 'level':6,54 'librari':55 'like':92 'longer':82 'low':5 'low-level':4 'maintain':84 'mani':57 'migrat':88 'ml':64 'name':65 'newer':90 'node.js':77 'ocaml/reasonml':7 'packag':26,79 'polyfil':75 'promis':94 'promise-fetch':93 'provid':27 'releas':22 'request':37 'requir':73 'respons':35 'response._type':71 'response.type':68 'safe':31 'solut':91 'stabl':17 'target':42 'thin':28 'type':30 'type-saf':29 'unlik':56 'user':85 'version':18 'xhr':103","created_at":"2026-06-07T16:50:16.488066+00:00","updated_at":"2026-06-07T16:50:16.488066+00:00","problems":[{"fix":"Replace `Bs_fetch` with `Fetch` in your code.","cause":"The deprecated Bs_fetch module is not available in newer versions; use Fetch instead.","error":"Error: Unbound module Bs_fetch"},{"fix":"Install isomorphic-fetch: `npm install isomorphic-fetch` and add `[%raw \"require('isomorphic-fetch')\"]` at the top of your main file.","cause":"fetch API is not available in Node.js without polyfill.","error":"ReferenceError: fetch is not defined (Node.js)"},{"fix":"Use `Response.type_` instead of `Response._type`.","cause":"Response._type was renamed to Response.type_ in version 0.6.0.","error":"Error: The variant type Response._type is not accessible (0.6.0+)"},{"fix":"Upgrade to bs-fetch >=0.3.0 or use Headers.make with array pairs.","cause":"Headers.makeWithDict was added in 0.3.0.","error":"Error: Unbound value Headers.makeWithDict (pre-0.3.0)"}],"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/reasonml-community/bs-fetch#readme","github":"https://github.com/reasonml-community/bs-fetch","docs":null,"changelog":null,"pypi":null,"npm":"bs-fetch","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}}