Create an article

Now we have a form, we can handle when the user submits it and then pass it to the API for to handle and turn into an article.

<script src="[email protected]/dist/index.js"></script>
<input type="text" name="title">
<textarea name="content" cols="80" rows="10"></textarea>
<button type="submit">Submit</button>
var form = document.getElementsByTagName('form')[0];
form.addEventListener('submit', function(e) {
var body = {
title: form.elements['title'].value,
content: form.elements['content'].value,
content_input_type: 'rte',
status: 'published'
// Send the article body to the API.
var client = new DeskproClient('');
client.setAuthKey(1, 'dev-admin-code');'/articles', body)
.then(function(resp) {
console.log('Article created with ID ' +;
.catch(function(err) {

Submitting the form should show you something like this in your debug console:

Article created with ID 107