{"id":16375964,"url":"https://github.com/brettz9/getjson","last_synced_at":"2025-09-27T20:30:38.198Z","repository":{"id":53610855,"uuid":"27736262","full_name":"brettz9/getJSON","owner":"brettz9","description":"Vanilla JS getJSON function","archived":false,"fork":false,"pushed_at":"2024-09-19T22:36:22.000Z","size":1671,"stargazers_count":4,"open_issues_count":7,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-08T18:57:04.030Z","etag":null,"topics":["getjson","json","promise"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brettz9.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE-MIT.txt","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":"2014-12-08T21:31:55.000Z","updated_at":"2024-09-19T22:34:41.000Z","dependencies_parsed_at":"2024-10-20T14:37:20.814Z","dependency_job_id":null,"html_url":"https://github.com/brettz9/getJSON","commit_stats":{"total_commits":103,"total_committers":3,"mean_commits":"34.333333333333336","dds":0.09708737864077666,"last_synced_commit":"302eaa28c6a1686bd80bffb70dab216f95cb5114"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettz9%2FgetJSON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettz9%2FgetJSON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettz9%2FgetJSON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettz9%2FgetJSON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brettz9","download_url":"https://codeload.github.com/brettz9/getJSON/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234455934,"owners_count":18835665,"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":["getjson","json","promise"],"created_at":"2024-10-11T03:22:50.235Z","updated_at":"2025-09-27T20:30:37.841Z","avatar_url":"https://github.com/brettz9.png","language":"JavaScript","funding_links":["https://issuehunt.io/r/brettz9/getJSON"],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/simple-get-json.svg)](https://www.npmjs.com/package/simple-get-json)\n[![Dependencies](https://img.shields.io/david/brettz9/getJSON.svg)](https://david-dm.org/brettz9/getJSON)\n[![devDependencies](https://img.shields.io/david/dev/brettz9/getJSON.svg)](https://david-dm.org/brettz9/getJSON?type=dev)\n\n[![eslint badge](https://raw.githubusercontent.com/brettz9/getJSON/master/badges/eslint-badge.svg?sanitize=true)](badges/eslint-badge.svg)\n[![eslint 3rd party badge](https://raw.githubusercontent.com/brettz9/getJSON/master/badges/eslint-third-party.svg?sanitize=true)](badges/eslint-third-party.svg)\n\n[![testing badge](https://raw.githubusercontent.com/brettz9/getJSON/master/badges/tests-badge.svg?sanitize=true)](badges/tests-badge.svg)\n[![coverage badge](https://raw.githubusercontent.com/brettz9/getJSON/master/badges/coverage-badge.svg?sanitize=true)](badges/coverage-badge.svg)\n\n[![Known Vulnerabilities](https://snyk.io/test/github/brettz9/getJSON/badge.svg)](https://snyk.io/test/github/brettz9/getJSON)\n[![Total Alerts](https://img.shields.io/lgtm/alerts/g/brettz9/getJSON.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/brettz9/getJSON/alerts)\n[![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/brettz9/getJSON.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/brettz9/getJSON/context:javascript)\n\n[![Filesize badge (UMD)](https://raw.githubusercontent.com/brettz9/getJSON/master/badges/filesize-browser-umd.svg?sanitize=true)](badges/filesize-browser-umd.svg)\n[![Filesize badge (ESM)](https://raw.githubusercontent.com/brettz9/getJSON/master/badges/filesize-browser-esm.svg?sanitize=true)](badges/filesize-browser-esm.svg)\n\u003c!--[![License](https://img.shields.io/npm/l/getJSON.svg)](LICENSE-MIT.txt)--\u003e\n[![Licenses badge](https://raw.githubusercontent.com/brettz9/getJSON/master/badges/licenses-badge.svg?sanitize=true)](badges/licenses-badge.svg)\n\n(see also [licenses for dev. deps.](https://raw.githubusercontent.com/brettz9/getJSON/master/badges/licenses-badge-dev.svg?sanitize=true))\n\n[![issuehunt-to-marktext](https://issuehunt.io/static/embed/issuehunt-button-v1.svg)](https://issuehunt.io/r/brettz9/getJSON)\n\n# getJSON\n\ngetJSON function similar to that of jQuery's.\n\nIf no callback or error-back is provided (or when an array of URLs is\nsupplied), a promise will be returned. If an array is provided along with\na callback, that callback will be executed before the promise is resolved.\n\nYou may use the file `index-es.js` to use the ES2017 `await` keyword for\nPromise results, as well as take advantage of ES6 Module import:\n\n```js\ntry {\n  const [urlObj1, urlObj2] = await getJSON([url1, url2]);\n} catch (err) {\n  // Handle errors here\n}\n```\n\n`simple-get-json` also accepts an array of URLs (waiting for all to load):\n\n```js\nconst [obj1, obj2] = await getJSON([url1, url2]);\n// Do something with \"obj1\" and \"obj2\"\n```\n\nAlternatively, you can use regular `then` Promises:\n\n```js\ngetJSON([url1, url2]).then(function (objsArr) {\n  // Do something with \"objsArr\" array\n}, function (err) {\n  // Handle any errors here\n  console.log('err', err);\n});\n```\n\nOr use the old callback style.\n\n```js\ngetJSON(url, function (data) {\n  // Do something with \"data\"\n});\n```\n\nAn optional third argument can be provided as an error-back (which will\nbe supplied the error message and originally supplied URL).\n\n## Install\n\n```\nnpm install simple-get-json\n```\n\n## Setup\n\n### Browser\n\n```html\n\u003c!--\nFor older browser support\n\u003cscript src=\"node_modules/core-js-bundle/minified.js\"\u003e\u003c/script\u003e\n--\u003e\n\u003cscript src=\"node_modules/simple-get-json/dist/index.js\"\u003e\u003c/script\u003e\n```\n\n```js\ngetJSON(...args);\n```\n\nor for ESM:\n\n1. Direct use:\n\n```js\nimport {getJSON} from './node_modules/simple-get-json/dist/index-es.js';\n```\n\n2. With a bundler:\n\n```js\nimport {getJSON} from 'simple-get-json';\n```\n\n\n### Node (CJS)\n\n```js\nconst {getJSON} = require('simple-get-json');\n```\n\nSee below for `buildGetJSON` usage.\n\n### Node (ESM)\n\nIn ESM Node, you can:\n\n1. Directly import the module (for use relative to the current working\n    directory):\n\n```js\nimport {getJSON} from 'simple-get-json';\n```\n\n2. Build a version of `getJSON` which works relative to the current file\n    (or some other URL):\n\n```js\nimport {buildGetJSON} from 'simple-get-json';\n\nconst getJSON = buildGetJSON({\n  baseURL: import.meta.url\n});\n```\n\nOR:\n\n3. Build a version of `getJSON` which works relative to a specific file\n    directory:\n\n```js\nimport {buildGetJSON} from 'simple-get-json';\n\nconst getJSON = buildGetJSON({\n  cwd: '/some/current/working/directory'\n});\n```\n\n## Todo\n\n- Support named parameters ala jQuery\n- Support rest of jQuery API\n- Make local or URL loading optional for Node\n\n## See also\n\n- [postJSON](https://github.com/brettz9/postJSON)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettz9%2Fgetjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrettz9%2Fgetjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettz9%2Fgetjson/lists"}