Skip to content

Commit fda9eae

Browse files
committed
2 parents b421750 + 50f287d commit fda9eae

File tree

4 files changed

+34
-19
lines changed

4 files changed

+34
-19
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ And that's it! Now you have a functioning Whatsapp Bot connected to your server.
8888

8989
## Running outside of Node.js
9090

91-
The module has a single dependecy, node-fetch, which brings fetch() into Node.js (although it is natively available from v17 and on).
92-
Starting from @0.4.0, the code will check if fetch is available in your enviroment and use it by default, with fallback to node-fetch.
93-
This will allow the same script to be run in differents enviroments, such as a web browsers, Deno, and maybe TypeScript, idk about this last one ¯\\\_(ツ)\_/¯.
91+
Since @0.4.0, the module uses cross-fetch, a cross compatible fetch function. IDK where it works, we will find out now.
92+
This will allow the same script to be run in differents enviroments, such as a web browsers, Deno,
93+
and maybe TypeScript, idk about this last one ¯\\\_(ツ)\_/¯.
9494
Personal suggestion, use [esm.sh](https://esm.sh/) to import the code directly from npm, works flawlessly with Deno.
9595

9696
Some examples:

fetch.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ const Location = require('./types/location');
55
const { Template } = require('./types/template');
66
const Text = require('./types/text');
77

8-
// Bad idea, I don't like var...
9-
if (typeof fetch === "undefined") var fetch = require('node-fetch');
8+
const fetch = require('cross-fetch');
109

1110
/**
1211
* Make a message post request to the API

package-lock.json

Lines changed: 25 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
"helper",
1818
"bot"
1919
],
20-
"dependencies": {
21-
"node-fetch": "^2.6.7"
20+
"repository": {
21+
"type": "git",
22+
"url": "https://github.com/Secreto31126/whatsapp-api-js.git"
2223
},
2324
"devDependencies": {
2425
"docdash": "^1.2.0",
2526
"jsdoc": "^3.6.10"
2627
},
27-
"repository": {
28-
"type": "git",
29-
"url": "git://github.com/Secreto31126/whatsapp-api-js.git"
28+
"dependencies": {
29+
"cross-fetch": "^3.1.5"
3030
}
3131
}

0 commit comments

Comments
 (0)