API

bosszepro

New Member
Feb 26, 2024
1
0
1
Hello,
I want to use proxmox API with nodejs. I read this: https://pve.proxmox.com/wiki/Proxmox_VE_API#NodeJS and I decided to use https://www.npmjs.com/package/proxmox
(doc is here: https://github.com/ttarvis/node-proxmox#readme). I don't know why but I have this error:
Code:
token.CSRF = response.data.CSRFPreventionToken;
                                       ^


TypeError: Cannot read properties of null (reading 'CSRFPreventionToken')
    at C:\Users\tomga\Documents\krabby\proxbot\utils\proxmox.js:70:33
    at C:\Users\tomga\Documents\krabby\proxbot\utils\proxmox.js:58:9
    at ChildProcess.exithandler (node:child_process:414:7)
    at ChildProcess.emit (node:events:514:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)


Node.js v20.10.0


This is my code:
Code:
proxmox = require("./proxmox")('user', 'password', 'domain');

proxmox.getClusterStatus(function(err, response){
if(err) throw err;
else{
  data = JSON.parse(response);
  console.log(data);
}
});

I tried to replace user by user@pve but I have the same issue.

Anyone can help me ?
Thank you in advance
 
Hi!
did you insert all the values correctly?
Make sure to substitute 'user' with 'root@pam' (with your username/realm obviously), 'password' with the users password and 'domain' with the ip-adress/domain-name.