Skip to content

Commit

Permalink
Merge pull request #2 from marcinx/main
Browse files Browse the repository at this point in the history
* replaces promise chains with async await for inactive HTTP request …
  • Loading branch information
marcinx authored Oct 1, 2022
2 parents fed0c40 + 46ae33d commit 0baf93c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function Client(transferServer) {
* @param params (object), a list of POST parameters to be included in the request
* @param callback (function), processes the response
*/
this.post = function(endpoint, params, callback) {
sendRequest('post', endpoint, params, callback);
this.post = async function(endpoint, params, callback) {
return await sendRequest('post', endpoint, params, callback);
};

/**
Expand All @@ -48,8 +48,8 @@ function Client(transferServer) {
* @param params (object), a list of PUT parameters to be included in the request
* @param callback (function), processes the response
*/
this.put = function(endpoint, params, callback) {
sendRequest('put', endpoint, params, callback);
this.put = async function(endpoint, params, callback) {
return await sendRequest('put', endpoint, params, callback);
};

/**
Expand All @@ -59,12 +59,12 @@ function Client(transferServer) {
* @param params (object), a list of DELETE parameters to be included in the request
* @param callback (function), processes the response
*/
this.delete = function(endpoint, params, callback) {
sendRequest('delete', endpoint, params, callback);
this.delete = async function(endpoint, params, callback) {
return await sendRequest('delete', endpoint, params, callback);
};

// private validator function
const validateArgs = function(method, endpoint, params) {
const validateArgs = function(method, endpoint, params) {

if (!validateEndpoint(endpoint)) {
this.log("Invalid endpoint given to " + method + " method.");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "COINQVEST LLC",
"name": "sep6-client",
"description": "Node JS based Stellar SEP-6 Client by COINQVEST",
"version": "0.0.1",
"version": "0.0.2",
"main": "./lib/index.js",
"keywords": [
"stellar",
Expand Down

0 comments on commit 0baf93c

Please sign in to comment.