Notice

Authentication and Validation is required for Create operations.

Create request will reach out to the Plattar API and create a new object with whatever is in the current .attributes fields. The object will be assigned a new unique ID by the Plattar API.

Perform a .create() operation
This example shows how to create a new Project
const {
	Project,
  	Server
} = require('@plattar/plattar-api');

Server.default().auth(process.env.PLATTAR_AUTH_TOKEN);

const project = new Project();
project.attributes.title = 'Your New Project Title';

// .create() function will create a brand new Object
// in the Plattar API.
project.create().then((proj) => {
	// this ID will be assigned by the Plattar API unique to this Object
	console.log(proj.id);
	// attributes will either be default values ot whatever was assigned
	console.log(proj.attributes);
}).catch((error) => {
	// creation failed. This can happen if invalid attributes
	// were sent for whatever reason
	console.error(error);
});