typeerror:input.charcodeat不是函数node.js restful api

xmakbtuz  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(326)

我想编码� 在我的api中使用此Library教程,但我收到错误:

TypeError: input.charCodeAt is not a function

这是api中的代码,我不知道在哪里可以编写函数,我想获得一些帮助示例来说明如何编写函数。

app.route('/stations')
  .get(function (req, res) {
    // omitted
    res.set({ 'content-type': 'application/json; charset=utf-8' });
    res.setHeader('Access-Control-Allow-Origin', '*', 'Cache-Control', 'private, no-cache, no-store, must-revalidate');

    pool.query(`SELECT * FROM sel_alert_level s;`, function (error, result) {
      if (error)
      return res.status(500).json({ error: "Грешна заявка. Опитай отново !"})
      stations = result;

      const encodedData = windows1251.encode(result, {
        'mode': 'json'
      });
      res.json({ encodedData })
    });
  });

所以我添加了这行代码:

const encodedData = windows1251.encode(result, {
    'mode': 'json'
  });

反而 res.json({ result}) 我把 encodedData 但这不起作用。。当我想输入api时,他给出了错误。。
首先,我使用的代码 var windows1251 = require('windows-1251') ..

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题