Get started with request CDN

Apache-2.0 licensed

The Request library is a simple solution for making asynchronous XMLHttpRequest to fetch data from servers.

Tags:
  • http
  • simple
  • util
  • utility

Stable version

Copied!

How to start using request CDN


// Include the request library from the CDN
const request = require('https');

// Define the options for the request
const options = {
  url: 'https://jsonplaceholder.typicode.com/todos/1',
  method: 'GET'
};

// Make the request and handle the response
request(options, (error, response, body) => {
  if (error) {
    console.error('Error:', error);
  } else if (response.statusCode !== 200) {
    console.log(`Status Code: ${response.statusCode}`);
  } else {
    const todo = JSON.parse(body);
    console.log(`Todo ID: ${todo.id}`);
    console.log(`Completed: ${todo.completed}`);
  }
});
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions