Fix json method signatures to match restler apis to pass json data. (#10736)

This commit is contained in:
ltrain777
2016-08-24 09:05:30 -07:00
committed by Masahiro Wakame
parent 324169800c
commit a94bce4fff
2 changed files with 24 additions and 6 deletions

View File

@@ -33,14 +33,28 @@ rest.post("http://user:pass@service.com/action", {
}
});
// post JSON
// post JSON with no options
var jsonData = { id: 334 };
rest.postJson("http://example.com/action", jsonData).on("complete", function(data, response) {
// handle response
});
// put JSON
// put JSON with no options
var jsonData = { id: 334 };
rest.putJson("http://example.com/action", jsonData).on("complete", function(data, response) {
// handle response
});
// post JSON with options
var jsonData = { id: 334 };
var options = { query: {"api-version": "1.0"}};
rest.postJson("http://example.com/action", jsonData, options).on("complete", function(data, response) {
// handle response
});
// put JSON with options
var jsonData = { id: 334 };
var options = { query: {"api-version": "1.0"}};
rest.putJson("http://example.com/action", jsonData, options).on("complete", function(data, response) {
// handle response
});

12
restler/restler.d.ts vendored
View File

@@ -40,10 +40,11 @@ declare module "restler" {
/**
* Send json data via GET method.
* @param {string} url A url address.
* @param {any} data JSON body
* @param {RestlerOptions} options Options.
* @return {RestlerResult} Result.
*/
json(url: string, options?: RestlerOptions): RestlerResult;
json(url: string, data?: any, options?: RestlerOptions, method?: string): RestlerResult;
/**
* Create a PATCH request.
@@ -56,10 +57,11 @@ declare module "restler" {
/**
* Send json data via PATCH method.
* @param {string} url A url address.
* @param {any} data JSON body
* @param {RestlerOptions} options Options.
* @return {RestlerResult} Result.
*/
patchJson(url: string, options?: RestlerOptions): RestlerResult;
patchJson(url: string, data?: any, options?: RestlerOptions): RestlerResult;
/**
* Create a POST request.
@@ -72,10 +74,11 @@ declare module "restler" {
/**
* Send json data via POST method.
* @param {string} url A url address.
* @param {any} data JSON body
* @param {RestlerOptions} options Options.
* @return {RestlerResult} Result.
*/
postJson(url: string, options?: RestlerOptions): RestlerResult;
postJson(url: string, data?: any, options?: RestlerOptions): RestlerResult;
/**
* Create a PUT request.
@@ -88,10 +91,11 @@ declare module "restler" {
/**
* Send json data via PUT method.
* @param {string} url A url address.
* @param {any} data JSON body
* @param {RestlerOptions} options Options.
* @return {RestlerResult} Result.
*/
putJson(url: string, options?: RestlerOptions): RestlerResult;
putJson(url: string, data?: any, options?: RestlerOptions): RestlerResult;
/**
* Create a PUT request.