Socket
Socket
Sign inDemoInstall

@types/superagent

Package Overview
Dependencies
4
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/superagent

TypeScript definitions for superagent


Version published
Weekly downloads
3.5M
decreased by-16.86%
Maintainers
1
Install size
2.02 MB
Created
Weekly downloads
 

Package description

What is @types/superagent?

The @types/superagent package provides TypeScript type definitions for the superagent library, which is a lightweight, progressive AJAX API crafted for flexibility, readability, and a low learning curve. This package doesn't add any new functionality to superagent itself but allows TypeScript developers to use superagent in their projects with type checking, autocompletion, and other TypeScript benefits.

What are @types/superagent's main functionalities?

Making GET requests

This feature allows you to make GET requests to retrieve data from a specified resource. The code sample demonstrates how to make a simple GET request to '/api/pets' and log the response body.

import request from 'superagent';

request.get('/api/pets').then(res => {
  console.log(res.body);
});

Posting data

This feature enables you to send data to a server using POST requests. The code sample shows how to post data to '/api/pets', sending an object with the name and species of a pet, and then logging the response body.

import request from 'superagent';

request.post('/api/pets')
  .send({ name: 'Milo', species: 'cat' })
  .then(res => {
    console.log(res.body);
  });

Setting headers

This feature allows you to set custom headers for your requests. In the code sample, a GET request is made to '/api/pets' with a custom 'API-Key' header.

import request from 'superagent';

request.get('/api/pets')
  .set('API-Key', 'foobar')
  .then(res => {
    console.log(res.body);
  });

Other packages similar to @types/superagent

Readme

Source

Installation

npm install --save @types/superagent

Summary

This package contains type definitions for superagent (https://github.com/visionmedia/superagent).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/superagent.

Additional Details

Credits

These definitions were written by Nico Zelaya, Michael Ledin, Pap Lőrinc, Shrey Jain, Alec Zopf, Adam Haglund, Lukas Elmer, Jesse Rogers, Chris Arnesen, Anders Kindberg, LuckyWind_sck, and David Tanner.

FAQs

Last updated on 22 Mar 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc