Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

300
Vistas
Uncaught (in promise) SyntaxError: Unexpected token 'const' in UI5 (SAP)

Hi I wanted to make an API Call in Ui5 but everytime it tells me, that it doesnt know whats 'Const'.

Uncaught SyntaxError: Unexpected token 'const' The following error occurred while displaying routing target with name 'TargetResult': SyntaxError: Unexpected token 'const' -
Uncaught (in promise) SyntaxError: Unexpected token 'const'

my Ui5 call:

sap.ui.define([
      "sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel"
    ], function(Controller, JSONModel) {
      "use strict";

      return Controller.extend("TESTE.TESTE.controller.ResultDevice", {

            onInit: function() {
              var sUrl = "/api/tablets?limit=1000&offset=0";
              const url = "https://jsonplaceholder.typicode.com/users";

              fetch(url).then(res => res.json()).then(res => (
                  const dataModel = new JSONModel(); dataModel.setData({
                    items: res
                  }); this.getView().setModel(dataModel, "aribadevices")

                )
              },
            },
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There are several issues with your curly braces and parenthesis. This code should work, doesn't have syntax errors, and is a little easier to read with each expression being on a new line.

sap.ui.define([
    "sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel"
  ], function(Controller, JSONModel) {
    "use strict";

    return Controller.extend("TESTE.TESTE.controller.ResultDevice", {

            onInit: function() {
            var sUrl = "/api/tablets?limit=1000&offset=0";
            const url = "https://jsonplaceholder.typicode.com/users";

            fetch(url).then(res => res.json()).then(res => {
                const dataModel = new JSONModel(); 
                dataModel.setData({
                    items: res
                }); 
                this.getView().setModel(dataModel, "aribadevices");
            })
        }
    })
});

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda