// 云函数入口文件
const cloud = require('wx-server-sdk')
const mysql = require('mysql2/promise')
cloud.init() // 使用当前云环境
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext=cloud.getWXContext()
try{
const connection =await mysql.createConnection({
host:"",
database:"xxs",
user:"root",
password:"",
port:"3306"
})
const[rows,fields]=await connection.execute("INSERT INTO integral_list (open_id,create_time) VALUES('"+ wxContext.OPENID +"' ,NOW() ) ")
const[rows1,fields1]=await connection.execute("UPDATE sys_customer SET integral = integral+1 WHERE open_id='"+ wxContext.OPENID +"' ")
connection.end();
return rows;
}
catch(err){
console.log("连接错误!",err)
return err;
}
}
这是代码,调用报错,实在找不到语法哪里有错误
WAServiceMainContext.js?t=wechat&s=1692146197700&v=2.33.0:1 Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '('
at Object.module.exports.load (:35115/var/runtime/node12/UserFunction.js:32)
at Runtime.handleOnce (:35115/var/runtime/node12/Runtime.engine.js:99)
at Timeout._onTimeout (:35115/var/runtime/node12/Runtime.engine.js:56)
at listOnTimeout (:35115/appservice/internal/timers.js:549)
at processTimers (:35115/appservice/internal/timers.js:492) (callId: 1692165600795-0.494791146595986) (trace: 14:0:0 start->14:0:1 system error (Error: errCode: -504002 functions execute fail | errMsg: Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '('
at Object.module.exports.load (:35115/var/runtime/node12/UserFunction.js:32)
at Runtime.handleOnce (:35115/var/runtime/node12/Runtime.engine.js:99)
at Timeout._onTimeout (:35115/var/runtime/node12/Runtime.engine.js:56)
at listOnTimeout (:35115/appservice/internal/timers.js:549)
at processTimers (:35115/appservice/internal/timers.js:492)), abort)
at O (<anonymous>:1:163208)
at <anonymous>:1:195232(env: Windows,mp,1.06.2306020; lib: 2.33.0)
有没有人帮忙看看啊
代码复制全了吗,最后少了一个 “}”