(endpoint, path, cb)
| 70 | } |
| 71 | |
| 72 | function getJSON(endpoint, path, cb) { |
| 73 | get(endpoint + path, function(rsp) { |
| 74 | var data, error = rsp.status != 200 ? 'status:' + rsp.status : 0; |
| 75 | try { |
| 76 | if (!error) |
| 77 | data = JSON.parse(rsp.string); |
| 78 | } catch (ex) { |
| 79 | error = ex; |
| 80 | } |
| 81 | cb(data, error); |
| 82 | }); |
| 83 | } |
| 84 | |
| 85 | function postJSON(endpoint, path, body, cb) { |
| 86 | post(endpoint + path, body, function(rsp) { |