小编ezg*_*ezg的帖子

在 Node.js 和 Knex 中向现有表添加一列

我正在使用 Node.js 和 Knex 为我的路由器构建服务。但是,我无法弄清楚如何向现有表中添加一列,任何帮助将不胜感激。另外,我正在使用 PostgreSQL,但我认为这对这个问题并不重要。

所以,这就是我向表中添加行的方法:

insertData(knex, table, row) {
  return knex
    .insert(row)
    .into(table)
    .returning('*')
    .then(rows => {
      return rows[0];
    });
}
Run Code Online (Sandbox Code Playgroud)

我猜在表中添加一列会与此类似吗?我只是无法弄清楚/找到解决方案。

javascript postgresql backend node.js knex.js

6
推荐指数
3
解决办法
9023
查看次数

React fetch, “credentials: include”,中断了我的整个请求,我得到一个错误

概括:

我正在 React 中向我的 Node.js 服务器执行获取请求。

每当我不包括credentials: "include"和 在我的获取请求中,请求就会成功地发送到服务器并返回给客户端。

但是,当我包含时credentials: "include",如下所示:

fetch('http://localhost:8000/',
    {   method: "GET", 
       'credentials': 'include',
        headers: new Headers({
            'Accept': 'application/json',
            'Access-Control-Allow-Origin':'http://localhost:3000/',
            'Content-Type': 'application/json',
    })

}) ....

Run Code Online (Sandbox Code Playgroud)

我收到此预检错误:

login:1 Access to fetch at 'http://localhost:8000/' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. …

javascript api ajax rest reactjs

5
推荐指数
2
解决办法
5203
查看次数

标签 统计

javascript ×2

ajax ×1

api ×1

backend ×1

knex.js ×1

node.js ×1

postgresql ×1

reactjs ×1

rest ×1