Skip to content

Commit

Permalink
Update example scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Mann committed Dec 2, 2017
1 parent a336733 commit 7ed5d34
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions examples/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ async function main() {

// Clients can either create new cryptographic keypairs, or load in a pre-defined
// pair of Curve25519 keys. In this situation, we will generate a new keypair.
let cryptoKeys = e3db.Client.generateKeypair();
let signingKeys = e3db.Client.generateSigningKeypair();
let cryptoKeys = await e3db.Client.generateKeypair();
let signingKeys = await e3db.Client.generateSigningKeypair();

console.log('Public Key: ' + cryptoKeys.publicKey)
console.log('Private Key: ' + cryptoKeys.privateKey)
Expand Down
2 changes: 1 addition & 1 deletion examples/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async function main() {

queryResult = await client.query(data, writer, record, type).next()
for (let record of queryResult) {
await client.delete(record.meta.record_id)
await client.delete(record.meta.recordId)
}
}

Expand Down
22 changes: 11 additions & 11 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,22 +624,22 @@ export default class Client {
url = this.config.apiUrl + '/v1/storage/records/safe/' + recordId + '/' + version
}

return oauthFetch(this, url, {
let response = await oauthFetch(this, url, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
}).then(response => {
switch (response.status) {
case 204:
case 403:
return Promise.resolve(true)
case 409:
throw new Error('Conflict')
default:
throw new Error('Error while deleting record data!')
}
})

switch (response.status) {
case 204:
case 403:
return Promise.resolve(true)
case 409:
throw new Error('Conflict')
default:
throw new Error('Error while deleting record data!')
}
}

/**
Expand Down

0 comments on commit 7ed5d34

Please sign in to comment.