You appear not to be using closures so your Amplify definitions are not available. You place your code inside an immediately invoked function expression (iife) as shown below. This will run your amplify definitions code and make the getSampleData
available as a property of the dataservice
object. So you call dataservice.getSampleData(...)
var dataservice = (function(amplify) {
var init = function() {
amplify.request.define("getSampleData", "ajax", {
url: "/SampleData/GetSampleData",
dataType: "json",
type: "GET"
});
},
getSampleData = function (callbacks) {
return amplify.request({
resourceId: "getSampleData",
success: callbacks.success,
error: callbacks.error
});
};
init();
return {
getSampleData: getSampleData
};
})(amplify);
Note that your use of knockout is also not correct. The ko.applyBindings
function takes a view model as the first parameter and a DOM element as an optional second parameter. Where is your view model?