正确输入所有数据后如何结束我的异步连接?即使在循环外声明连接结束,结构也在第一次 INSERT 之后完成代码require('es6-promise').polyfill();require('isomorphic-fetch');let queryAPI = { "query": `{ squads { name cards(includedOnKanban: true, closed: false, archived: false, cancelled: false, swimlaneName:\"Atividades Nao Transacionais\", updatedSince: \"2020-01-01T00:00:00-0300\") { identifier title description status priority assignees { fullname email } swimlane workstate } } }`};(async () => { const rawResponse = await fetch('https://www.bluesight.io/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Bluesight-API-Token': 'token-here' }, body: JSON.stringify(queryAPI) }); const content = await rawResponse.json(); const { Client } = require('pg'); const client = new Client({ user: 'postgres', host: '127.0.0.1', database: 'postgres', password: 'postgres', port: 5432 })输出错误:连接在连接处终止。(C:\Users\TESTE\Documents\Autoportal\api\node_modules\pg\lib\client.js:254:9) 在 Object.onceWrapper (events.js:417:28) 在 Connection.emit (events.js: 323:22)
1 回答
浮云间
TA贡献1829条经验 获得超4个赞
你可以尝试使用 await client.connect()
而且,对于您的查询,这
res = await client.query(query, parameters);
代替这个
client.query(query, parameters, (err, res) => {
console.log(err, res);
})
添加回答
举报
0/150
提交
取消