{"library":"najax","title":"Najax","description":"Najax is a lightweight Node.js library providing a jQuery-style API for making HTTP requests on the server-side. Released as version 1.0.7, it was last updated approximately five years ago, indicating an abandoned status. It offers methods like `$.get`, `$.post`, `najax()`, and supports callback-based asynchronous operations, handling SSL and making assumptions about request options that can be overridden. Unlike modern HTTP clients such as Axios or Node-fetch, Najax primarily uses a callback-based pattern, which has largely been superseded by Promises and `async/await` in contemporary JavaScript development. Its primary differentiator was simplifying Node.js HTTP requests with a familiar jQuery AJAX syntax at the time of its active development.","language":"javascript","status":"abandoned","last_verified":"Thu Apr 23","install":{"commands":["npm install najax"],"cli":null},"imports":["const najax = require('najax')","const $ = require('najax')","const najax = require('najax');\nnajax.get('http://example.com', callback);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const najax = $ = require('najax');\n\nconst successCallback = (data, status, xhr) => {\n  console.log('Request successful!');\n  console.log('Data:', data);\n  // For demonstration, exit process after successful request\n  process.exit(0);\n};\n\nconst errorHandler = (xhr, status, error) => {\n  console.error('Request failed!');\n  console.error('Status:', status);\n  console.error('Error:', error);\n  process.exit(1);\n};\n\n// Example 1: GET request with a callback\n$.get('http://jsonplaceholder.typicode.com/posts/1', successCallback);\n\n// Example 2: POST request with options and a callback\nnajax('http://jsonplaceholder.typicode.com/posts', { \n  type: 'POST', \n  data: JSON.stringify({ title: 'foo', body: 'bar', userId: 1 }),\n  headers: { 'Content-Type': 'application/json' }\n}, successCallback);\n\n// Example 3: POST request with chainable success/error handlers\nnajax({\n  url: 'http://jsonplaceholder.typicode.com/posts',\n  type: 'POST',\n  data: JSON.stringify({ title: 'hello', body: 'world', userId: 2 }),\n  headers: { 'Content-Type': 'application/json' }\n})\n.success(successCallback)\n.error(errorHandler);\n\n// Keep the process alive for async operations\nsetTimeout(() => {\n  console.log('Operations completed or timed out.');\n  process.exit(0);\n}, 5000);\n","lang":"javascript","description":"Demonstrates various ways to make HTTP requests using Najax, including GET and POST methods, with different callback and chainable error handling patterns.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}