Skip to Content
avatar image
Former Member

Load multiple service as a mock service in sapui5 app - hcp ?

Hi Experts,

I have a requirement where I have to load multiple mock services into my application(multiple metadata files need to load).

Please check the code below. I tried to load multiple services but that only loads the first oMockServer.start(); function then it gives a library error.

sap.ui.define([
	"sap/ui/core/util/MockServer"
], function(MockServer) {
	"use strict";
	return {
		init: function() {
			// create
			var oMockServer = new MockServer({
				rootUri: "/destinations/ABC/V2/ABC/ABC.svc/"
			});
			var oUriParameters = jQuery.sap.getUriParameters();
			// configure
			MockServer.config({
				autoRespond: true,
				autoRespondAfter: oUriParameters.get("serverDelay") || 1000
			});
			// simulate
			var sPath = "model/localService/test1";
			oMockServer.simulate(sPath + "/metadata.xml", sPath + "/mockdata");
			// start
			oMockServer.start();
			
			// simulate
			var sPath = "model/localService/test2";
			oMockServer.simulate(sPath + "/metadata.xml", sPath + "/mockdata");
			// start
			oMockServer.start();
		}
	};
});
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers