TypeError 需要 2 个参数 Javascript Python

问题描述

我有一些 js 代码,它们是从 python 中的控制器调用的。我遇到了 createdb() takes 2 arguments,1given 错误。我可以知道我应该在我的 js 函数中放什么吗?我还在学习 javascript。感谢您的理解。

.js

 $(function(){
        $("#start_trial").click(function(){
            createDatabase();
        });
    });

function createDatabase(){
        session.rpc('/custom/createdb',{
            db_name : db_name
        }).then(function() {
            console.log("Database created successfully");
            }); 
            
        },function () {
            console.log("calling /custom/createdb caused an exception!");
        });
    }

.py

 @http.route('/custom/createdb',type='json',auth="public",methods=["POST"],website=True)
    def createdb(self,db_name):
       
        session = self._authenticate()
        if not session:
            return json.dumps(False)

        # create a new database
        headers = {'Content-Type': 'application/json'}
        
        create_db_url = "http://localhost:8090/cus_cus/create_db"
        data = {"jsonrpc": 2.0,"params": { "name": db_name } }

        _logger.debug("Creating database...")
        r = session.post(url=create_db_url,data=json.dumps(data),headers=headers)

        if r.ok:
            return json.dumps(True)
        else:
            return json.dumps(False)
        

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)