{"id":18056009,"url":"https://github.com/argyleink/grunt-fetch-json","last_synced_at":"2025-04-05T09:44:03.614Z","repository":{"id":57255024,"uuid":"47297878","full_name":"argyleink/grunt-fetch-json","owner":"argyleink","description":"Fetch and stash remote JSON for your build system","archived":false,"fork":false,"pushed_at":"2016-02-07T00:54:34.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T13:30:40.780Z","etag":null,"topics":["grunt","jamstack","npm"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/argyleink.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-12-03T00:51:56.000Z","updated_at":"2017-03-02T21:30:48.000Z","dependencies_parsed_at":"2022-08-31T08:31:45.832Z","dependency_job_id":null,"html_url":"https://github.com/argyleink/grunt-fetch-json","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/argyleink%2Fgrunt-fetch-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/argyleink%2Fgrunt-fetch-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/argyleink%2Fgrunt-fetch-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/argyleink%2Fgrunt-fetch-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/argyleink","download_url":"https://codeload.github.com/argyleink/grunt-fetch-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318721,"owners_count":20919483,"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":["grunt","jamstack","npm"],"created_at":"2024-10-31T01:13:18.735Z","updated_at":"2025-04-05T09:44:03.578Z","avatar_url":"https://github.com/argyleink.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Getting Started\nThis plugin requires Grunt.\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-fetch-json --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('fetchJson');\n```\n\n## The \"fetchJson\" task\nThe goal here is simply to allow fetching of remote data sources for use in your app. A couple use cases include:\n- Passing the data to a templated build sytem (jade, handlebars, etc), ultimately creating static sites that are data driven\n- Taking work off your server and putting it into the build system\n- Eliminating ajax spinners from your client code, aka thinning out the client\n\nI'm sure the community will come up with plenty of other interesting use cases for this tool. Get creative!\n\n### Overview\nIn your project's Gruntfile, add a section named `fetchJson` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  fetchJson: {\n    options: {\n      // Task-specific options go here.\n    },\n    your_files: {\n      // Target-specific file lists and/or options go here.\n    },\n  },\n})\n```\n\n### Options\n\n#### options.method\nType: `String`\nDefault value: `'GET'`\n\nA string value that is passed with the fetch request.\n\n#### options.headers\nType: `Object`\nDefault value: `{}`\n\nAn object with keys and values you'd like passed with the fetch request.\n\n#### options.body\nType: `Object`\nDefault value: `{}`\n\nAn object with keys and values you'd like passed with the fetch request.\n\n#### options.parameters\nType: `Object`\nDefault value: `{}`\n\nAn object with keys and values you'd like appended to the request url.\n\n###### More options can be found here [node-fetch](https://www.npmjs.com/package/node-fetch).\n\n### Usage Examples\n\n#### Default Options\nIn this example, the default options are used to grab some json and stash it in a local file.\n\n```js\ngrunt.initConfig({\n  fetchJson: {\n    files: {\n      'data/remote_data1.json': 'http://jsonplaceholder.typicode.com/posts/1'\n    }\n  },\n})\n```\n\n#### Multiple File Options\nIn this example, we're fetching multiple files, in parallel.\n\n```js\ngrunt.initConfig({\n  fetchJson: {\n    files: {\n      'tmp/remote_data2.json': 'http://jsonplaceholder.typicode.com/posts/2',\n      'tmp/remote_data3.json': 'http://jsonplaceholder.typicode.com/posts/3'\n    }\n  },\n})\n```\n\n#### Fetch with parameters\nFetch json from an api with tokens or keys.\n\n```js\ngrunt.initConfig({\n  fetchJson: {\n    options: {\n      method: 'GET',\n      headers: {\n        'Accept':       'application/json',\n        'Content-Type': 'application/json'\n      },\n      parameters: {\n        access_token:   '555'\n      }\n    },\n    files: {\n      'tmp/shirts.json':  'https://yourapi.com/shirts',\n      'tmp/pants.json':   'https://yourapi.com/pants'\n    }\n  },\n})\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n* 2015-12-04  v0.0.3  Improved readme\n* 2015-12-03  v0.0.2  Improved naming convention\n* 2015-12-02  v0.0.1  Initial release\n\n## License\nCopyright (c) 2015 Adam Argyle. Licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fargyleink%2Fgrunt-fetch-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fargyleink%2Fgrunt-fetch-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fargyleink%2Fgrunt-fetch-json/lists"}