npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@to1source/request

v0.9.4

Published

Super simple http package using native http.request to replace the popular request package for our own use

Downloads

8

Readme

@to1source/request

Description

Super simple http package to replace the popular request npm for our own use

This is node.js ONLY package

Installation


$ npm i @to1source/request 

Instructions

The easiest way:

const request = require('@to1source/request')
// default it's a get 
request('http://example.com')
  .then(({result, res}) => {
    // do your thing 
  })
  .catch(err => {
    // when statusCode !== 200 
    // we are young, so we don't know how to handle 301 yet
    // it will be in the future release
  })

Using the main request will return a promise that resolve

  • result: whatever the server respond with, and we will try to parse it as JSON
  • res: the original respond object, you can further process it

Or you need to do post?


request('http://example.com', {method: 'post', formData: {id: 1}})
  .then(({result, res}) => {
    // do your thing 
  })
  .catch(err => {
    
  })

Short hands methods

If you don't care much about the processing, and just want a quick result. We recommend you to use the short methods intead.

Everthing short hand will only return the server respond result; this is different from using just the request call.

request.get

const request = require('@to1source/request')
request.get('http://example.com')
  .then(result => {
    // do your thing
  })

request.post

request.post('http://example.com', {id: 1})
  .then(result => {
    // do your thing 
  })

request.form

request.form('http://example.com', {id: 1})
  .then(result => {
    // do your thing 
  })

This method will set the header to multipart/form-data

@TODO file upload

request.jsonql

This is a special method purposely develop for our own jsonql framework

To include this one need to use a different path

const request = require('@to1source/request/jsonql')

request.jsonql('http://example.com', payload, config)
  .then(result => {
    // do our thing 
  })

Since this is a very special method develop as another part of our framework component, we are not going to go into detail here (it's much more complex that it looks). If you are interested. You can check out our jsonql website.


Contribution

  1. Fork the repository
  2. Create Feat_xxx branch
  3. Commit your code
  4. Create Pull Request

Gitee Feature

  1. You can use Readme_XXX.md to support different languages, such as Readme_en.md, Readme_zh.md
  2. Gitee blog blog.gitee.com
  3. Explore open source project https://gitee.com/explore
  4. The most valuable open source project GVP
  5. The manual of Gitee https://gitee.com/help
  6. The most popular members https://gitee.com/gitee-stars/

TO1SOURCE

NEWBRAN LTD