How to create topic from plugin?
Solved
NodeBB Plugins
-
Inside a plugin, you can call
Topics.post()
var Topics = require.main.require('./src/topics'); var payload = { cid: 1, // The category id title: 'the post title', content: 'some post content', uid: 1, // The user posting the topic. timestamp: Date.now() // When the post was created. }; Topics.post(payload, function(err, data) { if (err) console.log(err); });
I copied this from here.
https://github.com/NodeBB/nodebb-plugin-write-api/blob/master/routes/v1/topics.js#L20-L30
Copyright © 2024 NodeBB | Contributors