Socket
Socket
Sign inDemoInstall

@coffeekraken/s-request

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coffeekraken/s-request

Simple request class that make use of the AMAZING axios under the hood. The goal of this package is more to keep a single implementation for futur updates than anything else.


Version published
Weekly downloads
200
decreased by-38.65%
Maintainers
1
Weekly downloads
 
Created
Source

@coffeekraken/s-request

MIT 2.0.0-alpha.20 - Git repository

size downloads license discord

Simple request class that make use of the AMAZING axios under the hood. The goal of this package is more to keep a single implementation for futur updates than anything else.

Install

npm i @coffeekraken/s-request

Simple and effective HTTP request package based on Axios

This package allows you to make HTTP request simply with some feature like:

  • If the request url contains a hash like #something and that the response is some HTML, the returned data will be directly the HTMLElement if exists in the response.
  • And more to come as well...

You may ask "why don't use axios directly?". We just want to stay in control with our implementations and having the choice to make updates as we need...

Usage

Here's how to use our implementation:

import __SRequest from '@coffeekraken/s-request';
const request = new __SRequest({
  url: 'https://something.com...',
});
const result = await request.send();

Response schema
export default {
  status: 200,
  statusText: 'OK',
  data: {
    // data returned by the server...
  },
  count: 1,
  axiosResponse: {}, // raw axios response
  axiosResponses: [{}], // array of raw axios response(s)
};

Request parameters
SRequestParamsInterface
url *

The url of the request

baseUrl

Specify the base url to call like "https://api.github.com/2.0" for example. If the "url" setting is absolute, this setting will don't have any impact on your request...

method
GET

The request method to use like GET, DELETE, HEAD, POST, OPTIONS, PUT or PATCH

headers

Specify some headers to add to the request

params

Specify some params to be sent through the URL. Must be a plain object or a URLSearchParams object

data

Specify some data you want to send with the request. This setting is available only for `PUT`, `POST`, and `PATCH` requests...

timeout

Specify time to wait before aborting the actual request. If setted in number format, this will mean milliseconds.

transformRequest

Allows changes to the request data before it is sent to the server. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

transformResponse

Allows changes to the response data to be made before it is passed to then/catch. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

paramsSerializer

An optional function in charge of serializing. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

withCredentials

Indicates whether or not cross-site Access-Control requests should be made using credentials. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

auth

indicates that HTTP Basic auth should be used, and supplies credentials. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

responseType
json

Indicates encoding to use for decoding responses (Node.js only)

responseEncoding
utf8

indicates encoding to use for decoding responses (Node.js only). See [axios](https://github.com/axios/axios#response-schema) documentation for more.

xsrfCookieName
XSRF-TOKEN

The name of the cookie to use as a value for xsrf token

xsrfHeaderName
X-XSRF-TOKEN

The name of the http header that carries the xsrf token value

onUploadProgress

Allows handling of progress events for uploads browser only

onDownloadProgress

Allows handling of progress events for downloads browser only

maxContentLength

Defines the max size of the http response content in bytes allowed in node.js

maxBodyLength

(Node only option) defines the max size of the http request content in bytes allowed

validateStatus

Defines whether to resolve or reject the promise for a give HTTP response status code. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

maxRedirects
5

Defines the maximum number of redirects to follow in node.js

socketPath

Defines a UNIX Socket to be used in node.js. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

httpAgent

Define a custom agent to be used when performing http. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

httpsAgent

Define a custom agent to be used when performing https. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

proxy

Defines the hostname, port, and protocol of the proxy server. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

cancelToken

Specifies a cancel token that can be used to cancel the request. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

signal

an alternative way to cancel Axios requests using AbortController

decompress
1

indicates whether or not the response body should be decompressed automatically. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

insecureHTTPParser

Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers. See [axios](https://github.com/axios/axios#response-schema) documentation for more.

API

For more information about the API of this class, please check our API documentation

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Here's all the ways you can contact us listed:

discord email

FAQs

Package last updated on 15 Sep 2023

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