{"id":15679174,"url":"https://github.com/olebedev/go-duktape-fetch","last_synced_at":"2025-06-18T08:41:41.799Z","repository":{"id":33667419,"uuid":"37320030","full_name":"olebedev/go-duktape-fetch","owner":"olebedev","description":"Server side fetch polyfill for go-duktape  ","archived":false,"fork":false,"pushed_at":"2017-02-06T22:23:01.000Z","size":134,"stargazers_count":12,"open_issues_count":2,"forks_count":7,"subscribers_count":2,"default_branch":"v2","last_synced_at":"2025-05-07T09:50:06.457Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/olebedev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-12T12:10:55.000Z","updated_at":"2022-12-23T06:08:58.000Z","dependencies_parsed_at":"2022-08-07T23:00:05.081Z","dependency_job_id":null,"html_url":"https://github.com/olebedev/go-duktape-fetch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/olebedev/go-duktape-fetch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olebedev%2Fgo-duktape-fetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olebedev%2Fgo-duktape-fetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olebedev%2Fgo-duktape-fetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olebedev%2Fgo-duktape-fetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olebedev","download_url":"https://codeload.github.com/olebedev/go-duktape-fetch/tar.gz/refs/heads/v2","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olebedev%2Fgo-duktape-fetch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260521353,"owners_count":23021802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-10-03T16:26:35.104Z","updated_at":"2025-06-18T08:41:36.776Z","avatar_url":"https://github.com/olebedev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-duktape-fetch [![wercker status](https://app.wercker.com/status/fb4b5e19e7981f6aa9b0426deeaa1406/s \"wercker status\")](https://app.wercker.com/project/bykey/fb4b5e19e7981f6aa9b0426deeaa1406)\n\nFetch polyfill for [go-duktape](https://github.com/olebedev/go-duktape).\n\n### Usage\n\nFirst of all install the package `go get gopkg.in/olebedev/go-duktape-fetch.v2`.\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n\n  \"gopkg.in/olebedev/go-duktape.v2\"\n  \"gopkg.in/olebedev/go-duktape-fetch.v2\"\n)\n\nfunc main() {\n  // create an ecmascript context\n  ctx := duktape.New()\n  // push fetch into the global scope\n  fetch.PushGlobal(ctx, nil)\n  ch := make(chan string)\n  ctx.PushGlobalGoFunction(\"cbk\", func(c *duktape.Context) int {\n    ch \u003c- c.SafeToString(-1)\n    return 0\n  })\n  // make a request\n  ctx.PevalString(`\n    fetch('http://ya.ru').then(function(resp) {\n      return resp.text();\n    }).then(function(body) {\n      // release channel\n      cbk(body.slice(0, 15));\n    });\n  `)\n  // print head line of the response body\n  fmt.Println(\u003c-ch)\n}\n```\nThis program will prodice `\u003c!DOCTYPE html\u003e` into stdout.\n\nAlso you can define fetch with some other good possibilities. In \nparticular you can specify local http instance with `http.Handler` \ninterface as a the second parameter. It will be used for all local\nrequests which url starts with `/`(single slash). See [tests](https://github.com/olebedev/go-duktape-fetch/blob/master/fetch_test.go) \nfor more detail.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folebedev%2Fgo-duktape-fetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folebedev%2Fgo-duktape-fetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folebedev%2Fgo-duktape-fetch/lists"}