cancel
Showing results for 
Search instead for 
Did you mean: 

How to ready body output from xsjslib in UI5?

former_member594414
Participant
0 Kudos

Hi All,

I'm trying to execute a POST operation using xsjslib exit. In the xsjslib file, I have written my logic and at the end I'm also setting a output in the body as below

$.response.contentType = "application/json";
$.response.contentType = "text/plain";
$.response.setBody("Done");
}

Also, the controller.js file looks like below

var body = JSON.parse($.request.body.asString());
			oThis.insertService.create("/user", userdata, {
				success: function(oData, result) {
					console.log(body);
				},
				error: function(oError) {
					console.log(oError);
				}
			});
		},

Here my intention is to read the output set in the $.response.setBody("Done") in the console log. I have tried doing this using var body, but I'm not sure if this is the correct apporoach.

Pls help

pfefferf
Active Contributor
0 Kudos

Please can you add a little bit more details and clarify if you are not getting already errors with that coding (which I assume)?

With "POST operation using xsjslib exit" you mean an exit implementation for an XSOData service?

Controller.js: Is $.request.body.asString() an own implementation of you, because the XSJS implementation is not available on client side?

former_member594414
Participant
0 Kudos

Hi florian.pfeffer , Yes its "POST operation using xsjslib exit". Like using AJAX calls we return some JSON/any text output to UI, I would like to know if the same thing can be done using xsjslib. Is it possible?

Pls ignore the UI5 code

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

In general you can do such things in an xsjslib too, if you make the $.reponse object available in your xsjslib function. But it is not possible in the context of an XSOData exit implementation.

Answers (0)