cancel
Showing results for 
Search instead for 
Did you mean: 

Fetch Javascript API doesn't work on SCP Portal

alexandrefossati
Explorer

I have created a SAP UI5 App on my SCP Neo Trial Account and then I deployed this application to SAP Cloud Platform on HTML5 Application.

It works well on Web IDE and also works perfectly fine if I open the link that HTML5 Application have generated for me.

But when I put this same application into SCP Portal, the application still opens up, but all my Javascript Fetch calls does not work anymore.

Does SCP Portal not support fetch, or we need to set up something else?

Edit: Here's more info...

Fetch request:

fetch("/database/public/tests/xsjs/getDate.xsjs")
  .then(function(response) {
    return response.json();
  })
  .then(function(json1) {
    view.setModel(new JSONModel({text: json1.nowDate}), "XSJS");
  });

new JSONModel("/database/public/tests/xsjs/getDate.xsjs")
  .attachRequestCompleted({}, function(param) {
    view.setModel(new JSONModel({text: param.getSource().getData().nowDate}), "JSONMODEL");
  });

neo-app.json: (that's the only snippet where I refer to the destination)

{
  "path": "/database",
  "target": {
    "type": "destination",
    "name": "database"
  }
}

destination:

This is what I got when running the deployed HTML5 application to SAP Cloud Platform:

This is what I got when running this same deployed app, but in SCP Portal:

(The text under yellow is just a hardcoded string, that I put on page while the fetch request doesn't retrieve my response)

That's the error that I'm getting:

(I don't know why Portal is changing my URL request and pre fixing https://flpportal-p2001664935trial)

ibibhu
Product and Topic Expert
Product and Topic Expert

Can you please attach your fetch call code, neo-app.json, configured destination.

As there is no such thing like SCP Portal supports JavaScript Fetch or not as it's part of browser Web API.

Please refer the Fetch_API specification and it's browser compatibility .

alexandrefossati
Explorer
0 Kudos

I'm sorry for my late reply, I edited my post with more info

kaiomattos
Member
0 Kudos

Hello, i've the same problem, javascript fetch still doesn't work on SCP Portal on march of 2021.

Accepted Solutions (0)

Answers (1)

Answers (1)

gregorw
Active Contributor

My app iotui5v3 is deployed stand alone but also in the portal. It works without modification. And I think the reason is because I use the manifest.json to define the datasource of my OData model. I think you should do the same for your JSON model. That way the portal can influence the called URL. In my case instead of /destinations/XSOdataProxy when started standalone the called url is /sap/fiori/iotui5v3/destinations/XSOdataProxy when used in the Portal.

alexandrefossati
Explorer
0 Kudos

how can I declare a non odata service on dataSources of manifest.json?

gregorw
Active Contributor

Declare it as a JSON Model.