Skip to content

Commit

Permalink
Let's keep testing in production
Browse files Browse the repository at this point in the history
  • Loading branch information
Secreto31126 committed Jun 17, 2022
1 parent fda9eae commit 30666e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const Location = require('./types/location');
const { Template } = require('./types/template');
const Text = require('./types/text');

const fetch = require('cross-fetch');
const req = typeof fetch === "undefined" ? require('cross-fetch') : fetch;

/**
* Make a message post request to the API
Expand Down Expand Up @@ -33,7 +33,7 @@ function sendMessage(token, v, phoneID, to, object) {
});

// Make the post request
return fetch(`https://graph.facebook.com/${v}/${phoneID}/messages`, {
return req(`https://graph.facebook.com/${v}/${phoneID}/messages`, {
method: "POST",
headers: {
'Authorization': `Bearer ${token}`,
Expand All @@ -55,7 +55,7 @@ function sendMessage(token, v, phoneID, to, object) {
* @returns {Promise} The fetch promise
*/
function readMessage(token, v, phoneID, message_id) {
return fetch(`https://graph.facebook.com/${v}/${phoneID}/messages`, {
return req(`https://graph.facebook.com/${v}/${phoneID}/messages`, {
method: "POST",
headers: {
'Authorization': `Bearer ${token}`,
Expand Down Expand Up @@ -87,7 +87,7 @@ function makeQR(token, v, phoneID, message, format) {
prefilled_message: message,
};

return fetch(`https://graph.facebook.com/${v}/${phoneID}/message_qrdls?${new URLSearchParams(params)}`, {
return req(`https://graph.facebook.com/${v}/${phoneID}/message_qrdls?${new URLSearchParams(params)}`, {
method: "POST",
headers: {
'Authorization': `Bearer ${token}`,
Expand All @@ -107,7 +107,7 @@ function makeQR(token, v, phoneID, message, format) {
* @returns {Promise} The fetch promise
*/
function getQR(token, v, phoneID, id) {
return fetch(`https://graph.facebook.com/${v}/${phoneID}/message_qrdls/${id ?? ""}`, {
return req(`https://graph.facebook.com/${v}/${phoneID}/message_qrdls/${id ?? ""}`, {
headers: {
'Authorization': `Bearer ${token}`,
},
Expand All @@ -127,7 +127,7 @@ function getQR(token, v, phoneID, id) {
* @returns {Promise} The fetch promise
*/
function updateQR(token, v, phoneID, id, message) {
return fetch(`https://graph.facebook.com/${v}/${phoneID}/message_qrdls/${id}?prefilled_message=${encodeURI(message)}`, {
return req(`https://graph.facebook.com/${v}/${phoneID}/message_qrdls/${id}?prefilled_message=${encodeURI(message)}`, {
method: "POST",
headers: {
'Authorization': `Bearer ${token}`,
Expand All @@ -147,7 +147,7 @@ function updateQR(token, v, phoneID, id, message) {
* @returns {Promise} The fetch promise
*/
function deleteQR(token, v, phoneID, id) {
return fetch(`https://graph.facebook.com/${v}/${phoneID}/message_qrdls/${id}`, {
return req(`https://graph.facebook.com/${v}/${phoneID}/message_qrdls/${id}`, {
method: "DELETE",
headers: {
'Authorization': `Bearer ${token}`,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "whatsapp-api-js",
"version": "0.4.1",
"version": "0.4.2",
"author": "Secreto31126",
"description": "A Whatsapp Official API helper for Node.js",
"license": "MIT",
Expand Down

0 comments on commit 30666e7

Please sign in to comment.