Skip to content

Commit

Permalink
Merge branch 'feature/E10' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
YuFeng Deng committed Nov 2, 2019
2 parents 5bedbde + 7e6ed2d commit 6f6b619
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions myapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"hbs": "~4.0.4",
"http-errors": "~1.6.3",
"morgan": "~1.9.1",
"node-fetch": "^2.6.0",
"nodemon": "^1.19.2"
}
}
18 changes: 18 additions & 0 deletions myapp/routes/url-encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var express = require('express');
var router = express.Router();
const { check, validationResult } = require('express-validator');
const { sanitizeBody } = require('express-validator');
let fetch = require('node-fetch');

/* GET home page. */
router.get('/', function(req, res, next) {
Expand All @@ -23,6 +24,23 @@ function(req, res, next) {
let userInput = req.body;
userInput.email = encodeURIComponent(userInput.name);

let fetchOption = {};

let payload = {
"method": "sendMessage",
"chat_id": "-1001294676322",
"text": userInput.name,
};

fetchOption.method = "post";
fetchOption.body = JSON.stringify(payload);
fetchOption.headers = {};
fetchOption.headers["Content-Type"] = 'application/json';

let url = "http://localhost:8888";
url = "https://api.telegram.org/bot" + "682267360:AAHmjSil8oylavD2pENLLpcMU1svaD7mVeA" + "/";

fetch(url, fetchOption);

res.render('url-encoder', { title: 'Express', userInput: userInput, errors: errors.array(), validInput: errors.isEmpty()});
});
Expand Down

0 comments on commit 6f6b619

Please sign in to comment.