{"id":23222963,"url":"https://github.com/dckt/rescript-ky","last_synced_at":"2026-01-19T11:32:15.038Z","repository":{"id":222963577,"uuid":"758835808","full_name":"DCKT/rescript-ky","owner":"DCKT","description":"ReScript bindings for ky HTTP client","archived":false,"fork":false,"pushed_at":"2024-08-12T09:30:44.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T16:35:03.378Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"ReScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DCKT.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-17T08:09:02.000Z","updated_at":"2024-08-12T09:30:46.000Z","dependencies_parsed_at":"2024-02-17T10:29:59.151Z","dependency_job_id":"f08cbf78-eb27-4c96-8489-fe7eb40c92ea","html_url":"https://github.com/DCKT/rescript-ky","commit_stats":null,"previous_names":["dckt/rescript-ky"],"tags_count":13,"template":false,"template_full_name":"DCKT/rescript-bindings-template","purl":"pkg:github/DCKT/rescript-ky","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCKT%2Frescript-ky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCKT%2Frescript-ky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCKT%2Frescript-ky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCKT%2Frescript-ky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DCKT","download_url":"https://codeload.github.com/DCKT/rescript-ky/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCKT%2Frescript-ky/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28566395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T08:53:44.001Z","status":"ssl_error","status_checked_at":"2026-01-19T08:52:40.245Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-18T23:15:32.584Z","updated_at":"2026-01-19T11:32:15.020Z","avatar_url":"https://github.com/DCKT.png","language":"ReScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rescript-ky\n\nReScript bindings for [ky HTTP client](https://github.com/sindresorhus/ky) (targeted version : `~1.2.0`)\n\n## Setup\n\n1. Install the module\n\n```bash\nbun install @dck/rescript-ky\n# or\nyarn install @dck/rescript-ky\n# or\nnpm install @dck/rescript-ky\n```\n\n2. Add it to your `rescript.json` config\n\n```json\n{\n  \"bsc-dependencies\": [\"@dck/rescript-ky\"]\n}\n```\n\n## Usage\n\nThe functions can be accessed through `Ky` module.\n\n```rescript\ntype data = {anything: string}\ntype errorPayload = {\n  code: string\n}\n\nlet fetchSomething = async () =\u003e {\n  try {\n    let response: data = await Ky.fetch(\"test\", {prefixUrl: \"https://fake.com\", method: GET})-\u003eKy.Response.jsonFromPromise()\n    // handle response data\n  } catch {\n    | JsError(err) =\u003e {\n      let errorResponse = (err-\u003eKy.unkownToError).response-\u003eOption.getExn\n      let errorData: errorPayload = await errorResponse-\u003eKy.Response.json()\n\n      switch (errorData.code) {\n        | \"CODE_1\" =\u003e () // do something\n        | _ =\u003e ()\n      }\n    }\n  }\n}\n```\n\nUse shortcut method :\n\n```rescript\ntype data = {anything: string}\n\nlet fetchSomething = async () =\u003e {\n  try {\n    let response: data = await Ky.get(\"test\", {prefixUrl: \"https://fake.com\"})-\u003eKy.Response.jsonFromPromise()\n    // handle response data\n  } catch {\n    | JsError(err) =\u003e {\n      // handle err\n      Js.log(err)\n    }\n  }\n}\n```\n\n### Instance\n\n```rescript\nlet instance = Ky.Instance.create({prefixUrl: \"https://fake.com\"})\n\ntype data = {anything: string}\n\nlet fetchSomething = async () =\u003e {\n  try {\n    let response: data = await (instance-\u003eKy.Instance.get(\"test\"))-\u003eKy.Response.jsonFromPromise()\n    // handle response data\n  } catch {\n    | JsError(err) =\u003e {\n      // handle err\n      Js.log(err)\n    }\n  }\n}\n```\n\n### Extend\n\n```rescript\nlet instance = Ky.Instance.create({prefixUrl: \"https://fake.com\"})\nlet extendedInstance = instance-\u003eKy.Instance.extend({\n  prefixUrl: `${mockBasePath}/extend`,\n  headers: Ky.Headers.fromObj({\n    \"custom-header\": \"test\",\n  }),\n})\n\ntype data = {anything: string}\n\nlet fetchSomething = async () =\u003e {\n  try {\n    let response: data = await (extendedInstance-\u003eKy.Instance.get(\"test\"))-\u003eKy.Response.jsonFromPromise()\n    // handle response data\n  } catch {\n    | JsError(err) =\u003e {\n      // handle err\n      Js.log(err)\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdckt%2Frescript-ky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdckt%2Frescript-ky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdckt%2Frescript-ky/lists"}