From 1aa0c3153546d03cb4f2faf45dd6a88f7effdc64 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Tue, 19 Jan 2021 12:57:14 +0300 Subject: [PATCH] Made file reading sync --- server/index.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/server/index.js b/server/index.js index 580562f..e932aa1 100644 --- a/server/index.js +++ b/server/index.js @@ -1,6 +1,7 @@ import Express from "express"; import Cors from "cors"; import path from "path"; +import fs from "fs"; const __dirname = path.resolve(); import dotenv from 'dotenv'; @@ -17,17 +18,12 @@ app.use(Cors()); app.get('/update', (req, res) => { var id = statusIds[Math.floor(Math.random() * statusIds.length)]; - let token; - fs.readFile('../get-vk-token/token.txt', 'utf8', function(error, data) { - if (error) { - console.log(error); - } - token = data; - }); + let token = fs.readFileSync('../../get-vk-token/token.txt', 'utf8'); + console.log(token); let url = `https://api.vk.com/method/status.setImage?access_token=${token}&status_id=${id}&v=5.103`; httpsReq(url).then((response) => { console.log(response); - //res.redirect("https://status.anatolykopyl.ru"); + res.redirect("https://status.anatolykopyl.ru"); res.send(); }); });