@pitaj I've tried what you have said. No errors in host machine while listening on
./nodebb logthe only errors are in the Dev Tools Console Tab, so the request isn't ever even sent to the server (to my small amount of knowledge).
I'm trying to execute an api on a button click,
For example, the following command:
const api = await app.require('api');
await api.put(`/groups/test/membership/1550`);
Hi, you are executing an api command through a browser, I am looking for a way to embed this script in Nodbibi, and that it will be activated immediately when the page is loaded, (can also be done when a button is pressed).
But no option works, I tried onload, and it doesn't work. I tried with btn - to be activated with id. doesn't work either.
On the other hand, the script works by itself when you run it in the console.
Need urgent help, thanks!
const api = await app.require('api');
You can only use this from within browser dev console (and some limited other places).
Instead you should use
require(['api'], (api) => {
api.put(`/groups/test/membership/1550`).then(() => { ... });
});