Skip to content

Commit a616c78

Browse files
committed
AV.Cloud.rpc: 添加 JS Doc 注释,返回 rejected Promise 来表示错误
1 parent ac51fa0 commit a616c78

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/cloudfunction.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,19 @@ module.exports = function(AV) {
3434
})._thenRunCallbacks(options);
3535
},
3636

37+
/**
38+
* Makes a call to a cloud function, you can send {AV.Object} as param or a field of param; the response
39+
* from server will also be parsed as an {AV.Object}, array of {AV.Object}, or object includes {AV.Object}
40+
* @param {String} name The function name.
41+
* @param {Object} data The parameters to send to the cloud function.
42+
* @param {Object} options A Backbone-style options object.
43+
* @return {AV.Promise} A promise that will be resolved with the result of the function.
44+
*/
3745
rpc: function(name, data, options) {
38-
if (_.isArray(data))
39-
return console.warn('Can\'t pass Array as the param of rpc function in JavaScript SDK.');
46+
if (_.isArray(data)) {
47+
return AV.Promise.error(new Error('Can\'t pass Array as the param of rpc function in JavaScript SDK.'))
48+
._thenRunCallbacks(options);
49+
}
4050

4151
return AV._request('call', name, null, 'POST', AV._encodeObjectOrArray(data)).then(function(resp) {
4252
return AV._decode('', resp).result;

0 commit comments

Comments
 (0)