Merge pull request #1851 from timhunt/MOBILE-2951

MOBILE-2951 web-services: make it easier to debug web service calls
main
Juan Leyva 2019-04-26 15:55:31 +02:00 committed by GitHub
commit 348149af01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -234,7 +234,9 @@ export class CoreWSProvider {
args: this.convertValuesToString(data) args: this.convertValuesToString(data)
}]; }];
siteUrl = preSets.siteUrl + '/lib/ajax/service.php'; // The info= parameter has no function. It is just to help with debugging.
// We call it info to match the parameter name use by Moodle's AMD ajax module.
siteUrl = preSets.siteUrl + '/lib/ajax/service.php?info=' + method;
const promise = this.http.post(siteUrl, JSON.stringify(ajaxData)).timeout(CoreConstants.WS_TIMEOUT).toPromise(); const promise = this.http.post(siteUrl, JSON.stringify(ajaxData)).timeout(CoreConstants.WS_TIMEOUT).toPromise();
@ -547,8 +549,13 @@ export class CoreWSProvider {
options['responseType'] = 'text'; options['responseType'] = 'text';
} }
// We add the method name to the URL purely to help with debugging.
// This duplicates what is in the ajaxData, but that does no harm.
// POST variables take precedence over GET.
const requestUrl = siteUrl + '&wsfunction=' + method;
// Perform the post request. // Perform the post request.
const promise = this.http.post(siteUrl, ajaxData, options).timeout(CoreConstants.WS_TIMEOUT).toPromise(); const promise = this.http.post(requestUrl, ajaxData, options).timeout(CoreConstants.WS_TIMEOUT).toPromise();
return promise.then((data: any) => { return promise.then((data: any) => {
// Some moodle web services return null. // Some moodle web services return null.