我正在使用 cordova azure 移动应用程序插件连接到我的 azure 移动应用程序,其中我有一个自定义 API,我想从 cordova 客户端调用它但带有参数。
我看到了帖子How to call a custom function of Azure Mobile Service from Cordova mobile app?
这很有帮助,但它演示了不带参数的调用
我希望获得有关如何配置我的客户端以调用我的自定义 api 并向其发送参数的帮助
我的自定义 API 就像
[MobileAppController]
public class AirportsController : ApiController
{
public string GetByCode(int Code)
{
return Code.ToString();
}
}
我的 Cordova 客户端应该是什么样子:
client = new WindowsAzure.MobileServiceClient('https://MYAZURESITE.azurewebsites.net');
client.invokeApi('Airports/GetByCode', { method: 'GET' }).then(createKeySuccess, createKeyFailure);
那么我可以在哪里设置参数值?
最佳答案
您可以设置如下参数:
var options = {
method: 'GET',
parameters: {
param1: 'val1',
param2: 'val2'
}
}
client.invokeApi('Airports/GetByCode', options).then(createKeySuccess, createKeyFailure);
引用https://azure.github.io/azure-mobile-apps-js-client/MobileServiceClient.html#invokeApi详细的 API 引用。
关于cordova - 使用cordova调用azure移动应用自定义api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42607259/