How can I send fax using Express.js

1.3k views Asked by At

I found interfax in the npm. But not sure is it that I need. Can someone help me to find a right way for sending faxes using node+express?

1

There are 1 answers

1
Yevhenii Herasymchuk On BEST ANSWER

If you will take a look at source code of the interfax library, you can see that this library is using native node.js module https. You can read more about it here.

So you do not need express at all. Just go ahead with the documentation in the readme file.

But if you want to send fax after some endpoint call, you can do something like this:

const express = require('express');
const app = express();
const InterFAX = require('interfax');

// Initialize using parameters
const interfax = new InterFAX({
  username: '...',
  password: '...'
});

app.get('/sendFax', (req, res) => {
  // Send test file
 interfax.outbound.deliver({
   faxNumber: '+11111111112',
   file: 'folder/fax.txt'
 })
 .then(fax => {
   res.send('Fax sended');
 })
 .catch(error => {
   res.send('Error: ', error);
 });
});


app.listen(3000);