-
Notifications
You must be signed in to change notification settings - Fork 2
JSON Usage
Steven edited this page Feb 24, 2014
·
1 revision
This is a guide to cover the 4 basic operations of a paest (create, read, update, delete) using javascript. The usage is very similar to that of the CLI.
The main differences are:
- append '.json' to the urls
- send json objects (the normal thing to do in posts in js anyway)
Note: For the examples, I'm using jquery. This is just for convenience, angular, raw XMLHttpRequests, etc work too.
// Simple paest creation.
$.post("http://a.pae.st/.json", {'d':'content'}, function(response){
});
You can also pass in requested paest ids
// Simple paest creation.
$.post("http://a.pae.st/PaestIdIWant.json", {'d':'content'}, function(response){
});
The responses you get will be in the form
Object {
web_pub: "http://pae.st/XXX",
web_pri: "http://pae.st/XXX/YYYY",
cli_pub: "http://a.pae.st/XXX",
cli_pri: "http://a.pae.st/XXX/YYYY"
}
$.get("http://a.pae.st/XXX.json", function(response){
});
The responses will be either of:
{d:'paest data'} // Found
{e:'paest not found'} //Not found
Works the same as creating a paest except the url contains the private key too
// Simple paest update.
$.post("http://a.pae.st/XXX/YYYY.json", {'d':'new content'}, function(response){
});
Simply update with empty content
// Simple paest update.
$.post("http://a.pae.st/XXX/YYYY.json", {'d':''}, function(response){
});