superagent
| Property | Value |
|---|---|
| Package | superagent |
| Versions Covered | >=3.7.0 |
| Contract Version | 1.0.0 |
| Status | production |
| Last Verified | 2026-02-26 |
| Maintainer | corpus-team |
Installation
npm install superagent
Covered Functions
This contract covers 7 function(s):
get()
Makes HTTP GET request
Import:
import { get } from 'superagent';
Postconditions
What happens after calling this function:
🔴 ERROR - network-error-handling
Condition: network failure, DNS error, timeout, connection refused, HTTP 4xx/5xx errors
Throws: Error with status, response, timeout fields (Promise rejection)
Required Handling:
Use try-catch (async/await) or .catch() (promises) or .end() callback
📖 Source
post()
Makes HTTP POST request
Import:
import { post } from 'superagent';
Postconditions
What happens after calling this function:
🔴 ERROR - network-error-handling
Condition: network failure, DNS error, timeout, connection refused, HTTP 4xx/5xx errors
Throws: Error with status, response, timeout fields (Promise rejection)
Required Handling:
Use try-catch (async/await) or .catch() (promises) or .end() callback
📖 Source
put()
Makes HTTP PUT request
Import:
import { put } from 'superagent';
Postconditions
What happens after calling this function:
🔴 ERROR - network-error-handling
Condition: network failure, DNS error, timeout, connection refused, HTTP 4xx/5xx errors
Throws: Error with status, response, timeout fields (Promise rejection)
Required Handling:
Use try-catch (async/await) or .catch() (promises) or .end() callback
📖 Source
patch()
Makes HTTP PATCH request
Import:
import { patch } from 'superagent';
Postconditions
What happens after calling this function:
🔴 ERROR - network-error-handling
Condition: network failure, DNS error, timeout, connection refused, HTTP 4xx/5xx errors
Throws: Error with status, response, timeout fields (Promise rejection)
Required Handling:
Use try-catch (async/await) or .catch() (promises) or .end() callback
📖 Source
delete()
Makes HTTP DELETE request
Import:
import { delete } from 'superagent';
Postconditions
What happens after calling this function:
🔴 ERROR - network-error-handling
Condition: network failure, DNS error, timeout, connection refused, HTTP 4xx/5xx errors
Throws: Error with status, response, timeout fields (Promise rejection)
Required Handling:
Use try-catch (async/await) or .catch() (promises) or .end() callback
📖 Source
del()
Makes HTTP DELETE request (IE-compatible alias)
Import:
import { del } from 'superagent';
Postconditions
What happens after calling this function:
🔴 ERROR - network-error-handling
Condition: network failure, DNS error, timeout, connection refused, HTTP 4xx/5xx errors
Throws: Error with status, response, timeout fields (Promise rejection)
Required Handling:
Use try-catch (async/await) or .catch() (promises) or .end() callback
📖 Source
head()
Makes HTTP HEAD request
Import:
import { head } from 'superagent';
Postconditions
What happens after calling this function:
🔴 ERROR - network-error-handling
Condition: network failure, DNS error, timeout, connection refused, HTTP 4xx/5xx errors
Throws: Error with status, response, timeout fields (Promise rejection)
Required Handling:
Use try-catch (async/await) or .catch() (promises) or .end() callback
📖 Source
Example: Proper Error Handling
import superagent from 'superagent';
async function example() {
try {
const result = await get(/* args */);
// Handle success
return result;
} catch (error) {
// Handle error according to contract postconditions
console.error('Error:', error);
throw error;
}
}