New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →
Socket
Sign inDemoInstall
Socket

wonderful-fetch

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wonderful-fetch - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

3

dist/index.js

@@ -19,2 +19,3 @@ (function (root, factory) {

var jetpack;
var path;

@@ -24,3 +25,3 @@ var environment = (Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]') ? 'node' : 'browser';

var SOURCE = 'library';
var VERSION = '1.1.4';
var VERSION = '1.1.5';

@@ -27,0 +28,0 @@ function WonderfulFetch(url, options) {

{
"name": "wonderful-fetch",
"version": "1.1.4",
"version": "1.1.5",
"description": "A wrapper around fetch.",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -32,6 +32,6 @@ <p align="center">

## Wonderful Fetch Works in Node AND browser environments
## 🌐 Wonderful Fetch Works in Node AND browser environments
Yes, this module works in both Node and browser environments, including compatibility with [Webpack](https://www.npmjs.com/package/webpack) and [Browserify](https://www.npmjs.com/package/browserify)!
## Features
## ⚡ī¸ Features
* Intuitive error handling

@@ -43,3 +43,25 @@ * Download files directly to drive

## Install Wonderful Fetch
## đŸĒĻ The old way
You have to manually check if the response is `ok` and then parse the response as JSON.
```js
fetch('https://httpbin.org/json')
.then((response) => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then((data) => console.log(data))
.catch((error) => console.error(error));
```
## đŸĻ„ The Wonderful Fetch way
With Wonderful Fetch, you can automatically parse the response as JSON and handle all http errors with a single line of code.
```js
wonderfulFetch('https://httpbin.org/json', {response: 'json'})
.then((response) => console.log(response))
.catch((error) => console.error(error));
```
## đŸ“Ļ Install Wonderful Fetch
### Install via npm

@@ -67,3 +89,3 @@ Install with npm if you plan to use `wonderful-fetch` in a Node project or in the browser.

## Using Wonderful Fetch
## 🚀 Using Wonderful Fetch
After you have followed the install step, you can start using `wonderful-fetch` to make requests to any URL

@@ -102,16 +124,46 @@

#### Examples
##### Basic Fetch
Perform a basic fetch request.
```js
wonderfulFetch('https://httpbin.org/status/200', {method: 'get'});
wonderfulFetch('https://httpbin.org/status/200', {method: 'get'})
.then((response) => console.log(response))
.catch((error) => console.error(error));
```
## Extending Capabilities
##### Basic Fetch JSON
Perform a basic fetch request and return the response as JSON.
```js
wonderfulFetch('https://httpbin.org/status/200', {method: 'get', response: 'json'})
.then((response) => console.log(response))
.catch((error) => console.error(error));
```
##### Download File
Download a file to the specified `download` path. Node.js only.
```js
wonderfulFetch('https://httpbin.org/image/png', {download: './image.png'})
.then((response) => console.log(response))
.catch((error) => console.error(error));
```
##### Handle Errors with `catch`
Handle errors with the `catch` method.
```js
wonderfulFetch('https://httpbin.org/status/404', {method: 'get'})
.then((response) => console.log(response))
.catch((error) => console.error(error));
```
## 📚 Extending Capabilities
For a more in-depth documentation of this library and the Wonderful Fetch service, please visit the official Wonderful Fetch website.
## What Can Wonderful Fetch do?
## ❓ What Can Wonderful Fetch do?
Wonderful Fetch is a free fetch api that helps you make requests in Node.js or the browser.
## Final Words
## 📝 Final Words
If you are still having difficulty, we would love for you to post a question to [the Wonderful Fetch issues page](https://github.com/itw-creative-works/wonderful-fetch/issues). It is much easier to answer questions that include your code and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)
## Projects Using this Library
## 🎉 Projects Using this Library
[Somiibo](https://somiibo.com/): A Social Media Bot with an open-source module library. <br>

@@ -118,0 +170,0 @@ [JekyllUp](https://jekyllup.com/): A website devoted to sharing the best Jekyll themes. <br>

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