Skip to main content

got

PropertyValue
Packagegot
Versions Covered>=11.0.0
Contract Version1.0.0
Statusundefined
Last Verified2026-02-26
Maintainercorpus-team

Installation

npm install got

Covered Functions

This contract covers 6 function(s):

default()

Makes HTTP request (supports all HTTP methods via options or got.get/post/etc)

Import:

import { default } from 'got';

Postconditions

What happens after calling this function:

🔴 ERROR - network-error-handling

Condition: network failure, DNS error, timeout, connection refused, HTTP errors

Throws: RequestError or HTTPError (Promise rejection)

Required Handling:

Use try-catch (async/await) or .catch() (promises)

📖 Source


get()

Makes HTTP GET request

Import:

import { get } from 'got';

Postconditions

What happens after calling this function:

🔴 ERROR - network-error-handling

Condition: network failure, DNS error, timeout, connection refused, HTTP errors

Throws: RequestError or HTTPError (Promise rejection)

Required Handling:

Use try-catch (async/await) or .catch() (promises)

📖 Source


post()

Makes HTTP POST request

Import:

import { post } from 'got';

Postconditions

What happens after calling this function:

🔴 ERROR - network-error-handling

Condition: network failure, DNS error, timeout, connection refused, HTTP errors

Throws: RequestError or HTTPError (Promise rejection)

Required Handling:

Use try-catch (async/await) or .catch() (promises)

📖 Source


put()

Makes HTTP PUT request

Import:

import { put } from 'got';

Postconditions

What happens after calling this function:

🔴 ERROR - network-error-handling

Condition: network failure, DNS error, timeout, connection refused, HTTP errors

Throws: RequestError or HTTPError (Promise rejection)

Required Handling:

Use try-catch (async/await) or .catch() (promises)

📖 Source


delete()

Makes HTTP DELETE request

Import:

import { delete } from 'got';

Postconditions

What happens after calling this function:

🔴 ERROR - network-error-handling

Condition: network failure, DNS error, timeout, connection refused, HTTP errors

Throws: RequestError or HTTPError (Promise rejection)

Required Handling:

Use try-catch (async/await) or .catch() (promises)

📖 Source


patch()

Makes HTTP PATCH request

Import:

import { patch } from 'got';

Postconditions

What happens after calling this function:

🔴 ERROR - network-error-handling

Condition: network failure, DNS error, timeout, connection refused, HTTP errors

Throws: RequestError or HTTPError (Promise rejection)

Required Handling:

Use try-catch (async/await) or .catch() (promises)

📖 Source


Example: Proper Error Handling

import got from 'got';

async function example() {
try {
const result = await default(/* args */);
// Handle success
return result;
} catch (error) {
// Handle error according to contract postconditions
console.error('Error:', error);
throw error;
}
}

See Also