Can I use the api using just js


I’ve signed up for the hosted version of discourse. On my site I want to dynamically create a ‘comments’ area at the bottom of each page and dynamically create the content of the first post. Can I do that using just js and the api, I dont have access to a serverside language. Can it be done?

(Khoa Nguyen) #2

That’s possible. You just need to set cor header to interact with your discourse api. But create post require api key. And you are sending it unsecured


passing the api key unsecured is not great.
Instead I’ll include a link on my site to a page on the forum where they can post. I can pass the info I need in that url. Is there a ‘new post’ url I can direct them to?

(Khoa Nguyen) #4

If so, you can search about embed discourse. Discourse has a wordpress plugin and embed function for this situation

(Kane York) #5

If you do the cross-domain XHR “with credentials” (see the jQuery documentation), then it will be performed with the user’s login in Discourse.