Registry / devops / grunt-fetch-json

grunt-fetch-json

JSON →
library0.0.5jsnpmunverified

Grunt plugin to fetch remote JSON resources and save them locally. Current stable version is 0.0.5, last released in 2015. It uses node-fetch under the hood to make HTTP requests. This plugin is built for Grunt-based build pipelines and allows configuring method, headers, body, and parameters per task. It fetches JSON data from remote APIs and stores the responses as local files. This plugin is now obsolete in favor of modern build tools like Gulp or direct use of node-fetch. No active maintenance, package is deprecated.

npm install grunt-fetch-json
INSTALL
IMPORT
SIG · GRUNT-FETCH-JSON
G
grunt-fetch-json
devopsjavascriptv0.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetchJson
grunt.loadNpmTasks('grunt-fetch-json');
grunt.loadNpmTasks('fetchJson');
The grunt plugin register is 'fetchJson' but the npm package is 'grunt-fetch-json'. Always use the full npm package name in loadNpmTasks.
grunt.initConfig
grunt.initConfig({ fetchJson: { ... } });
grunt.initConfig({ 'fetchJson': { ... } });
Either form works, but typically the task name is used as a key without quotes.
task target
fetchJson: { files: { 'dest.json': 'http://example.com/data.json' } }
fetchJson: { src: 'http://...', dest: '...' }
This plugin uses a files object with dest as key and src as value, not standard grunt files array.

Example Gruntfile that fetches a single JSON file from a remote API and saves it locally.

// Install: npm install grunt-fetch-json --save-dev // Gruntfile.js module.exports = function(grunt) { grunt.loadNpmTasks('grunt-fetch-json'); grunt.initConfig({ fetchJson: { options: { method: 'GET', parameters: { access_token: process.env.API_KEY ?? '' } }, files: { 'tmp/data.json': 'https://jsonplaceholder.typicode.com/posts/1' } } }); grunt.registerTask('default', ['fetchJson']); };
Debug
Known issues
deprecatedThis package is deprecated. No updates since 2015. Use modern tools like node-fetch directly or Gulp.
fix
Replace with direct use of node-fetch or a modern build tool.
affects: all
gotchaThe task registration call uses grunt.loadNpmTasks('grunt-fetch-json') but the plugin itself registers a task named 'fetchJson'. The correct call is grunt.loadNpmTasks('grunt-fetch-json').
fix
Use grunt.loadNpmTasks('grunt-fetch-json') exactly.
affects: all
gotchaThe files object is inverted: key is destination, value is source URL. This is opposite of standard Grunt src/dest format.
fix
Use { 'dest.json': 'http://source.url' } instead of { src: '...', dest: '...' }.
affects: all
breakingOnly supports JSON responses. Fetching non-JSON will cause parsing errors.
fix
Ensure endpoints return valid JSON or handle response yourself.
affects: all
gotchaOptions.parameters are appended as query string, but they may conflict with URL already containing parameters.
fix
Check final URL or use node-fetch directly for more control.
affects: all
Errors
Common errors & fixes
Warning: Task "fetchJson" not found. Use --force to continue.
Missing or incorrect grunt.loadNpmTasks call.
fix
Add grunt.loadNpmTasks('grunt-fetch-json'); to your Gruntfile.
Aborted due to warnings.
Fetching a non-JSON resource or network error.
fix
Ensure the URL returns valid JSON and is reachable.
TypeError: Invalid protocol
URL missing protocol (e.g., http://).
fix
Include full URL with protocol.
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies
gruntrequiredGrunt is a peer dependency required to load and run the plugin.
node-fetchrequiredUsed to make HTTP requests to fetch remote JSON.
Agent activity
6 hits · last 30 days
node
6
Resources
grunt-fetch-json — npm install grunt-fetch-json · libregistry