Skip to content

How use with EXPRESS #178

Answered by Secreto31126
williamneves asked this question in Q&A
Discussion options

You must be logged in to vote

No need to shout 🤣

Here's a small snippet of a express server using the library:

import express from 'express';
import WhatsAppAPI from 'whatsapp-api-js';

const app = express();

const Whatsapp = new WhatsAppAPI({
    token: "Your Token goes here",
    appSecret: "Your App Secret goes here",
    webhookVerifyToken: "Your webhook key goes here"
});

// This entry handles the server auth against Meta's website
app.get("/", async (req, res) => {
    try {
        res.send(await Whatsapp.get(req.query));
    } catch (e) {
        res.sendStatus(e);
    }
});

// This entry handles server updates, such as messages and statuses
app.post("/", async (req, res) => {
    let code;
    try {
        

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@williamneves
Comment options

Answer selected by williamneves
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants