Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

request-json

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-json

HTTP client for very simple usages and JSON requests only

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
516
decreased by-85.3%
Maintainers
1
Weekly downloads
 
Created
Source

About

Request is a great client for NodeJS, but if you deal only with JSON, things could be more straightforward. This lib aims to simplify Request usage for JSON only requests.

Install

Add it to your package json or run:

npm install request-json

How it works

Client = require('request-json').JsonClient
client = new Client 'http://localhost:8888/'

data = title: 'my title', content: 'my content'
client.post 'posts/', data, (err, res, body) ->
    print response.statusCode

client.get 'posts/', (err, res, body) ->
    print body.rows[0].title

data = title: "my new title"
client.put 'posts/123/', (err, res, body) ->
    print response.statusCode

client.del 'posts/123/', (err, res, body) ->
    print response.statusCode

Extra : files

data = name: "test"
client.sendFile 'attachments/', './test.png', data, (err, res, body) ->
    console.log err if err

client.saveFile 'attachments/test.png', './test-get.png', (err, res, body) ->
    console.log err if err
    resultStats = fs.statSync('./test-get.png')

Extra : basic authentication

client.setBasicAuth('john', 'secret')
client.get 'private/posts/', (err, res, body) ->
    print body.rows[0].title

Keywords

FAQs

Package last updated on 23 Nov 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc