Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Secreto31126 committed Jun 17, 2022
2 parents b421750 + 50f287d commit fda9eae
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ And that's it! Now you have a functioning Whatsapp Bot connected to your server.

## Running outside of Node.js

The module has a single dependecy, node-fetch, which brings fetch() into Node.js (although it is natively available from v17 and on).
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.
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 ¯\\\_(ツ)\_/¯.
Since @0.4.0, the module uses cross-fetch, a cross compatible fetch function. IDK where it works, we will find out now.
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 ¯\\\_(ツ)\_/¯.
Personal suggestion, use [esm.sh](https://esm.sh/) to import the code directly from npm, works flawlessly with Deno.

Some examples:
Expand Down
3 changes: 1 addition & 2 deletions fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const Location = require('./types/location');
const { Template } = require('./types/template');
const Text = require('./types/text');

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

/**
* Make a message post request to the API
Expand Down
34 changes: 25 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"helper",
"bot"
],
"dependencies": {
"node-fetch": "^2.6.7"
"repository": {
"type": "git",
"url": "https://github.com/Secreto31126/whatsapp-api-js.git"
},
"devDependencies": {
"docdash": "^1.2.0",
"jsdoc": "^3.6.10"
},
"repository": {
"type": "git",
"url": "git://github.com/Secreto31126/whatsapp-api-js.git"
"dependencies": {
"cross-fetch": "^3.1.5"
}
}

0 comments on commit fda9eae

Please sign in to comment.