1.0.3 • Published 5 months ago

simple-sam-fetch v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

simple-sam-fetch

simple-sam-fetch is a lightweight and simple wrapper around the native fetch API to handle GET, POST, PUT, and DELETE requests with ease. It supports different response types such as json, blob, text, and arrayBuffer.

Installation

To install the package, run:

npm install simple-sam-fetch

usage

To install the package, run:

get(url, options = {})
Makes a GET request to the provided url and returns the response.

url: The URL of the API endpoint.
options: Optional settings like headers, responseType, etc.
post(url, data, options = {})
Makes a POST request to the provided url with the given data and returns the response.

url: The URL of the API endpoint.
data: The data to send with the POST request (automatically JSON stringified).
options: Optional settings like headers, responseType, etc.
put(url, data, options = {})
Makes a PUT request to the provided url with the given data and returns the response.

url: The URL of the API endpoint.
data: The data to send with the PUT request (automatically JSON stringified).
options: Optional settings like headers, responseType, etc.
delete(url, options = {})
Makes a DELETE request to the provided url and returns the response.

url: The URL of the API endpoint.
options: Optional settings like headers, responseType, etc.
Response Types
You can specify the response type by passing the responseType option in the options parameter. The following types are supported:

json: Default response type (parses the response as JSON).
blob: Useful for binary data (such as images or files).
text: For plain text responses.
arrayBuffer: For binary data, especially useful for file downloads.
1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago