Skip to main content
100%

Gist f25f852eb839dbcd3dd2a6c7048c37ee

✓ Published0🌍 Public
PPeleke
Last edited May 12, 2016
Created on May 12, 2016

This example demonstrates a promise-based HTTP wrapper for fetching data from the JSONPlaceholder API. The code defines a `makeRequest` function that constructs a request path from user-supplied command-line arguments, using Node’s built-in `http` module to send a GET request to `jsonplaceholder.typicode.com`. It parses the response body as JSON and resolves the promise with the parsed data, while rejecting with an error message for non-200 status codes. The module exports the function for reuse.

AI-generated description

Similar vizzes