How to use onFailure method in wpt

Best JavaScript code snippet using wpt

activities.js

Source:activities.js Github

copy

Full Screen

1/*global Mingus*/2jsBoot.add(Mingus.xhr.digest).as('digest');3jsBoot.use('jsBoot.service.core');4jsBoot.pack('LxxlLib.service', function(api) {5 'use strict';6 var requestor = api.core.requestor;7 var SERVICE = 'activities';8 var CMD_SEEN = 'seen';9 var CMD_REPORT = 'report';10 var CMD_UNREPORT = 'unreport';11 var CMD_PUBLISH = 'publish';12 var CMD_UNPUBLISH = 'unpublish';13 var CMD_THUMBNAIL = 'thumbnail';14 var CMD_MEDIA = 'media';15 var CMD_ATTACHMENT = 'attachment';16 var CMD_MINE = 'mine';17 var CMD_REPORTED = 'reported';18 var CMD_PUBLISHED = 'published';19 var wrapIt = function(callback) {20 return function(e) {21 delete e.details.error;22 //console.error('NETWORKERROR', JSON.stringify(e));23 // var info = $('.network-crash div');24 // info.html(info.html() + '<pre style="whitespace: pre;">' + JSON.stringify(e) + '</pre>');25 // $('.network-crash').show();26 callback();27 };28 };29 this.activities = new (function() {30 this.list = function(onSuccess, onFailure) {31 requestor.query(requestor.GET, {32 service: SERVICE,33 onsuccess: onSuccess,34 onfailure: wrapIt(onFailure),35 command: '#'36 });37 };38 this.listMine = function(onSuccess, onFailure) {39 requestor.query(requestor.GET, {40 service: SERVICE,41 onsuccess: onSuccess,42 onfailure: wrapIt(onFailure),43 command: CMD_MINE44 });45 };46 this.listReported = function(onSuccess, onFailure, params) {47 params = params || {};48 var p = {};49 Object.keys(params).forEach(function(key) {50 p['published.' + key] = params[key];51 });52 requestor.query(requestor.GET, {53 service: SERVICE,54 onsuccess: onSuccess,55 onfailure: wrapIt(onFailure),56 command: CMD_REPORTED,57 params: p58 });59 };60 this.listPublished = function(onSuccess, onFailure, params) {61 params = params || {};62 var p = {};63 Object.keys(params).forEach(function(key) {64 p['published.' + key] = params[key];65 });66 requestor.query(requestor.GET, {67 service: SERVICE,68 onsuccess: onSuccess,69 onfailure: wrapIt(onFailure),70 command: CMD_PUBLISHED,71 params: p72 });73 };74 this.create = function(onSuccess, onFailure, payload) {75 requestor.query(requestor.POST, {76 service: SERVICE,77 onsuccess: onSuccess,78 onfailure: wrapIt(onFailure),79 // XXX Dirty trick while manu fixes his internal redirects lacking trailing slash80 command: '#',81 payload: payload || {}82 });83 };84 this.addThumbnail = function(onSuccess, onFailure, id, payload) {85 requestor.query(requestor.POST, {86 service: SERVICE,87 onsuccess: onSuccess,88 onfailure: wrapIt(onFailure),89 id: id,90 command: CMD_THUMBNAIL,91 payload: payload || {}92 });93 };94 this.addMedia = function(onSuccess, onFailure, id, payload) {95 requestor.query(requestor.POST, {96 service: SERVICE,97 onsuccess: onSuccess,98 onfailure: wrapIt(onFailure),99 id: id,100 command: CMD_MEDIA,101 payload: payload || {}102 });103 };104 this.addAttachment = function(onSuccess, onFailure, id, payload) {105 requestor.query(requestor.POST, {106 service: SERVICE,107 onsuccess: onSuccess,108 onfailure: wrapIt(onFailure),109 id: id,110 command: CMD_ATTACHMENT,111 payload: payload || {}112 });113 };114 /*115 this.removeAttachment = function(onSuccess, onFailure, id, aid) {116 requestor.query(requestor.DELETE, {117 service: SERVICE,118 onsuccess: onSuccess,119 onfailure: wrapIt(onFailure),120 id: id,121 command: CMD_ATTACHMENT + '/' + aid122 });123 };124 */125 this.patch = function(onSuccess, onFailure, id, payload) {126 requestor.query(requestor.POST, {127 service: SERVICE,128 onsuccess: onSuccess,129 onfailure: wrapIt(onFailure),130 // XXX Dirty trick while manu fixes his internal redirects lacking trailing slash131 id: id,132 command: '#',133 payload: payload || {}134 });135 };136 this.read = function(onSuccess, onFailure, id) {137 requestor.query(requestor.GET, {138 service: SERVICE,139 onsuccess: onSuccess,140 onfailure: wrapIt(onFailure),141 id: id,142 command: '#'143 });144 };145 this.readUrl = function(id) {146 return requestor.url({147 service: SERVICE,148 onsuccess: function() {},149 onfailure: wrapIt(function() {}),150 id: id,151 command: 'public'152 });153 };154 this.remove = function(onSuccess, onFailure, id) {155 requestor.query(requestor.DELETE, {156 service: SERVICE,157 onsuccess: onSuccess,158 onfailure: wrapIt(onFailure),159 id: id,160 command: '#'161 });162 };163 this.publish = function(onSuccess, onFailure, id) {164 requestor.query(requestor.POST, {165 service: SERVICE,166 onsuccess: onSuccess,167 onfailure: wrapIt(onFailure),168 id: id,169 command: CMD_PUBLISH170 });171 };172 this.unpublish = function(onSuccess, onFailure, id) {173 requestor.query(requestor.POST, {174 service: SERVICE,175 onsuccess: onSuccess,176 onfailure: wrapIt(onFailure),177 id: id,178 command: CMD_UNPUBLISH179 });180 };181 this.seen = function(onSuccess, onFailure, id) {182 requestor.query(requestor.POST, {183 service: SERVICE,184 onsuccess: onSuccess,185 onfailure: wrapIt(onFailure),186 id: id,187 command: CMD_SEEN188 });189 };190 this.report = function(onSuccess, onFailure, id) {191 requestor.query(requestor.POST, {192 service: SERVICE,193 onsuccess: onSuccess,194 onfailure: wrapIt(onFailure),195 id: id,196 command: CMD_REPORT197 });198 };199 this.unreport = function(onSuccess, onFailure, id) {200 requestor.query(requestor.POST, {201 service: SERVICE,202 onsuccess: onSuccess,203 onfailure: wrapIt(onFailure),204 id: id,205 command: CMD_UNREPORT206 });207 };208 })();209});210/*211Add thumbnail : /X.Y/activities/AID/thumbnail -> return blob212add media : /X.Y/activivties/AID/media -> return blob213add attachments : add media : /X.Y/activivties/AID/attachment -> return blob214update blob : /X.Y/blob/blobid/ [POST]215remove blob : /X.Y/blob/blobid/ [DELETE] -> get blob : /X.Y/blob/blobid/(draft|published)216publish / unpublish fait le ménage automatique dans les blobs217activity.draft.blobs218activity.published.blobs219-> {'thumbnail' : ['id'], 'media' : ['id', 'id'], 'attachments' : ['id'...]]}22018:54221filtres sur la commande list :222/X.Y/activities/ (all)223/X.Y/activities/mine (mine only)224/X.Y/activities/published225/X.Y/activities/reported226pour filtrer : ?author.uid=227possible de chercher sur n'importe quelle key228?draft.matter.id =229?draft.difficulty.id=easy...

Full Screen

Full Screen

user.js

Source:user.js Github

copy

Full Screen

1/*global Mingus*/2jsBoot.add(Mingus.xhr.digest).as('digest');3jsBoot.use('jsBoot.service.core');4jsBoot.pack('LxxlLib.service', function(api) {5 'use strict';6 var requestor = api.core.requestor;7 // User sub commands8 var SERVICE = 'users';9 var ACL = 'acl';10 var USER_PROFILE = 'profile';11 var USER_AVATAR = 'avatar';12 var USER_SETTINGS = 'settings';13 var USER_PREFERENCES = 'preferences';14 var USER_REMINDER = 'reminder';15 var USER_DEACTIVATE = 'deactivate';16 var CHANGE_PASSWORD = 'password';17 // var USER_CMD_LIST = 'list';18 this.user = new (function() {19 this.list = function(onSuccess, onFailure) {20 requestor.query(requestor.GET, {21 service: SERVICE,22 onsuccess: onSuccess,23 onfailure: onFailure24 // command: USER_CMD_LIST25 });26 };27 this.deactivate = function(onSuccess, onFailure, uid) {28 requestor.query(requestor.POST, {29 service: SERVICE,30 onsuccess: onSuccess,31 onfailure: onFailure,32 id: uid,33 command: USER_DEACTIVATE34 });35 };36 this.changePassword = function(onSuccess, onFailure, uid, newPass) {37 requestor.query(requestor.POST, {38 service: SERVICE,39 onsuccess: onSuccess,40 onfailure: onFailure,41 id: uid,42 command: CHANGE_PASSWORD,43 payload: {44 password: newPass45 }46 });47 };48 this.reminderChangePassword = function(onSuccess, onFailure, email, code, password) {49 requestor.query(requestor.POST, {50 service: SERVICE,51 onsuccess: onSuccess,52 onfailure: onFailure,53 command: USER_REMINDER,54 payload: {55 email: email,56 code: code,57 password: password58 }59 });60 };61 this.reminderRequestPassword = function(onSuccess, onFailure, email) {62 requestor.query(requestor.GET, {63 service: SERVICE,64 onsuccess: onSuccess,65 onfailure: onFailure,66 command: USER_REMINDER + '?email=' + email67 });68 };69 this.profile = new (function() {70 this.push = function(onSuccess, onFailure, payload, id) {71 requestor.query(requestor.POST, {72 service: SERVICE,73 onsuccess: onSuccess,74 onfailure: onFailure,75 id: id || api.core.id,76 command: USER_PROFILE,77 payload: payload78 });79 };80 this.pull = function(onSuccess, onFailure, id) {81 requestor.query(requestor.GET, {82 service: SERVICE,83 onsuccess: onSuccess,84 onfailure: onFailure,85 id: id || api.core.id,86 command: USER_PROFILE87 });88 };89 })();90 this.acl = new (function() {91 this.push = function(onSuccess, onFailure, id, level) {92 requestor.query(requestor.POST, {93 service: SERVICE,94 onsuccess: onSuccess,95 onfailure: onFailure,96 id: id,97 command: ACL + '/' + (level == 3 ? 'admin' : 'author'),98 payload: {}99 });100 };101 })();102 this.preferences = new (function() {103 this.push = function(onSuccess, onFailure, payload) {104 requestor.query(requestor.POST, {105 service: SERVICE,106 onsuccess: onSuccess,107 onfailure: onFailure,108 id: api.core.id,109 command: USER_PREFERENCES,110 payload: payload111 });112 };113 this.pull = function(onSuccess, onFailure, id) {114 requestor.query(requestor.GET, {115 service: SERVICE,116 onsuccess: onSuccess,117 onfailure: onFailure,118 id: id || api.core.id,119 command: USER_PREFERENCES120 });121 };122 })();123 this.settings = new (function() {124 this.push = function(onSuccess, onFailure, payload) {125 requestor.query(requestor.POST, {126 service: SERVICE,127 onsuccess: onSuccess,128 onfailure: onFailure,129 id: api.core.id,130 command: USER_SETTINGS,131 payload: payload132 });133 };134 this.pull = function(onSuccess, onFailure, id) {135 requestor.query(requestor.GET, {136 service: SERVICE,137 onsuccess: onSuccess,138 onfailure: onFailure,139 id: id || api.core.id,140 command: USER_SETTINGS141 });142 };143 })();144 this.avatar = new (function() {145 this.push = function(onSuccess, onFailure, payload, id) {146 requestor.query(requestor.POST, {147 service: SERVICE,148 onsuccess: onSuccess,149 onfailure: onFailure,150 id: id || api.core.id,151 command: USER_AVATAR,152 payload: payload153 });154 };155 this.remove = function(onSuccess, onFailure, id) {156 requestor.query(requestor.DELETE, {157 service: SERVICE,158 onsuccess: onSuccess,159 onfailure: onFailure,160 id: id || api.core.id,161 command: USER_AVATAR162 });163 };164 this.getUrl = function(id) {165 /*jshint regexp:false*/166 var url = '/' + requestor.version + '/' + SERVICE;167 if (id)168 url += '/' + id;169 // var seed = Math.round(Math.abs((url.charCodeAt(url.length - 5) - 28) / 10));170 // var crap = requestor.hostPort.replace(/^([^.]+)(\..*)/, '$1' + seed + '$2');171 url += '/' + USER_AVATAR;172 return '//' + requestor.hostPort + url;173 };174 })();175 })();...

Full Screen

Full Screen

LoginHelper.ts

Source:LoginHelper.ts Github

copy

Full Screen

...4export class LoginHelper {5 public login(username: string, password: string, callback: LoginCallback) {6 const call: CurlCall = new APIHelper().getKeyCall();7 call.enqueue(new class implements CurlCallback {8 onFailure(call: CurlCall, exception: CurlToolException, requestId: number) {9 callback.onFailure(-101, "网络请求失败", exception)10 }11 onResponse(call: CurlCall, response: CurlResponse, requestId: number) {12 if (response.code() === 200){13 try {14 const result = JSON.parse(response.body());15 if (result["code"] === 200){16 const password_encrypted: string = RSAStaticUnit.encrypted(17 result["key"], result["hash"] + password18 );19 call = new APIHelper().getLoginCall(username, password_encrypted);20 call.enqueue(new class implements CurlCallback {21 onFailure(call: CurlCall, exception: CurlToolException, requestId: number) {22 callback.onFailure(-101, "网络请求失败", exception)23 }24 onResponse(call: CurlCall, response: CurlResponse, requestId: number) {25 LoginHelper.parse(response, callback)26 }27 }())28 } else {29 callback.onFailure(-104, result["message"]);30 }31 } catch (e) {32 callback.onFailure(-103, e.message);33 }34 } else {35 callback.onFailure(-105, "服务器内部出错");36 }37 }38 }())39 }40 public springboard(access: string, callback: SpringboardCallback){41 const call = new APIHelper(access).getSpringboardCall()42 call.enqueue(new class implements CurlCallback {43 onFailure(call: CurlCall, exception: CurlToolException, requestId: number) {44 callback.onFailure(-101, "网络请求失败", exception)45 }46 onResponse(call: CurlCall, response: CurlResponse, requestId: number) {47 if (response.code() === 200){48 try {49 const result = JSON.parse(response.body());50 if (result["code"] === 200){51 callback.onResult(result["location"]);52 } else {53 callback.onFailure(-114, result["message"]);54 }55 } catch (e) {56 callback.onFailure(-113, e.message);57 }58 } else {59 callback.onFailure(-115, "服务器内部出错");60 }61 }62 }())63 }64 public refreshToken(access_token: string, refresh_token: string, callback: LoginCallback){65 const call = new APIHelper(access_token, refresh_token).getRefreshTokenCall();66 call.enqueue(new class implements CurlCallback {67 onFailure(call: CurlCall, exception: CurlToolException, requestId: number) {68 callback.onFailure(-111, "网络请求失败", exception)69 }70 onResponse(call: CurlCall, response: CurlResponse, requestId: number) {71 LoginHelper.parse(response, callback)72 }73 }())74 }75 private static parse(response: CurlResponse, callback: LoginCallback) {76 if (response.code() === 200){77 try {78 const result = JSON.parse(response.body());79 if (result["code"] === 200){80 callback.onResult(result["access_token"], result["refresh_token"]);81 } else {82 callback.onFailure(-104, result["message"]);83 }84 } catch (e) {85 callback.onFailure(-103, e.message);86 }87 } else {88 callback.onFailure(-105, "服务器内部出错");89 }90 }91}92export interface LoginCallback {93 onFailure(code: number, message?: string, e?: CurlToolException): void94 onResult(access: string, refresh: string): void95}96export interface SpringboardCallback {97 onFailure(code: number, message?: string, e?: CurlToolException): void98 onResult(location: string): void...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptHook = require('wptHook');2wptHook.onFailure(function(){3 console.log('test failed');4});5wptHook.onSuccess(function(){6 console.log('test passed');7});8### wptHook.onFailure(callback)9### wptHook.onSuccess(callback)10### wptHook.onComplete(callback)11### wptHook.onBefore(callback)12### wptHook.onAfter(callback)13The MIT License (MIT)14This module is inspired by the [grunt-webpagetest](

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt.on('error', function(err) {2 console.error('Error: %s', err.message);3});4 if (err) {5 console.error('Error: %s', err.message);6 } else {7 console.log('Test Results: %j', data);8 }9});10wpt.on('error', function(err) {11 console.error('Error: %s', err.message);12});13 if (err) {14 console.error('Error: %s', err.message);15 } else {16 console.log('Test Results: %j', data);17 }18});19wpt.on('error', function(err) {20 console.error('Error: %s', err.message);21});22 if (err) {23 console.error('Error: %s', err.message);24 } else {25 console.log('Test Results: %j', data);26 }27});28wpt.on('error', function(err) {29 console.error('Error: %s', err.message);30});31 if (err) {32 console.error('Error: %s', err.message);33 } else {34 console.log('Test Results: %j', data);35 }36});37wpt.on('error', function(err) {38 console.error('Error: %s', err.message);39});40 if (err) {41 console.error('Error

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2var wptObj = new wpt('API_KEY');3var options = {4};5wptObj.runTest(options, function(err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 }11}, function(err, data) {12 console.log(data);13});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful