mirror of
https://github.com/oceanprotocol/webtasks
synced 2025-01-09 05:14:51 +01:00
31 lines
746 B
JavaScript
31 lines
746 B
JavaScript
|
'use strict' // eslint-disable-line
|
||
|
|
||
|
const express = require('express')
|
||
|
const axios = require('axios')
|
||
|
const webtask = require('webtask-tools')
|
||
|
|
||
|
const app = express()
|
||
|
|
||
|
app.get('/', (req, res) => {
|
||
|
res.send('Please specify the list ID and use POST request.')
|
||
|
})
|
||
|
|
||
|
app.get('/:list/:data', (req, res) => {
|
||
|
const options = {
|
||
|
method: 'post',
|
||
|
url: `https://api2.moonmail.io/lists/${req.params.list}/recipients`,
|
||
|
headers: { 'x-api-key': req.webtaskContext.secrets.MOONMAIL_API_KEY },
|
||
|
data: req.params.data,
|
||
|
}
|
||
|
|
||
|
axios(options)
|
||
|
.then(response => {
|
||
|
res.send(response)
|
||
|
})
|
||
|
.catch(error => {
|
||
|
res.send(error)
|
||
|
})
|
||
|
})
|
||
|
|
||
|
module.exports = webtask.fromExpress(app)
|