@KOHb96

Как решить проблему с исполнением скрипта node.js?

Всем привет, я новичек в JS, с синтаксисом знаком со вчера. Пытаюсь запустить сервер, который будет шифровать текст отправленый на него post запросом, но столкнулся с ошибкой:
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at Function.from (buffer.js:333:9)
    at c:\Users\artur\Desktop\Coding\server for naga.com\app.js:6:25
    at Layer.handle [as handle_request] (c:\Users\artur\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (c:\Users\artur\node_modules\express\lib\router\index.js:317:13)
    at c:\Users\artur\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (c:\Users\artur\node_modules\express\lib\router\index.js:335:12)
    at next (c:\Users\artur\node_modules\express\lib\router\index.js:275:10)
    at expressInit (c:\Users\artur\node_modules\express\lib\middleware\init.js:40:5)
    at Layer.handle [as handle_request] (c:\Users\artur\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (c:\Users\artur\node_modules\express\lib\router\index.js:317:13)


Код скрипта:
const crypto = require('crypto');
const express = require("express");
const app = express();

app.use("/generate", function(request, response){
const password = Buffer.from(request.query.password, 'base64');

const hash = crypto.createHash('sha256')
.update("$2a$10$0.o/S/w/i/p/e/S/A/L/T/"+password)
.digest('base64');
response.end('HASH:'+ hash + ';')
});
app.listen(5555);


Ввиду незнания языка, прошу помощи у знающих.
  • Вопрос задан
  • 272 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы