SAP UI5 Node.js SQLite

Need help with the following ui5 application using node.js, sqlite. The server.js looks like this

// File: server.js
const express = require("express");
const sqlite3 = require("sqlite3").verbose();
const cors = require('cors');

//app.use(cors({
//  origin: 'http://localhost:8080'
//}));

const app = express();
const PORT = process.env.PORT || 3000;

// Initialize SQLite in-memory database
const db = new sqlite3.Database(":memory:");

// Create table and insert sample data
db.serialize(() => {
  db.run("CREATE TABLE IF NOT EXISTS MyTable (id INTEGER PRIMARY KEY, name TEXT)");
  db.run("INSERT INTO MyTable (name) VALUES ('John')");
});

// API endpoint to fetch data from SQLite database
app.get("/api/data", (req, res) => {
  db.all("SELECT * FROM MyTable", (err, rows) => {
    if (err) {
      console.error(err.message);
      res.status(500).json({ error: "Internal Server Error" });
    } else {
      res.json(rows);
    }
  });
});

// Example of a new endpoint
app.get("/api/other-data", (req, res) => {
  // This is just a placeholder example endpoint
  res.json({ message: "This is some other data from the server." });
});

// Start the server
app.listen(PORT, () => {
  console.log(`Server is running on http://localhost:${PORT}`);
});

After executing ui5 serve, Server started. Clinking on the URL generated http://localhost:8080, the application starts, trying the fetch data and getting the error Error fetching data: The requested resource was not found.

//View1.controller.js

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

        return Controller.extend("ui5sql.ui5sql.controller.View1", {
            onInit: function () {

            },

            fetchDataFromNodeServer: function() {
              fetch("/api/data")
                  .then(response => {
                      if (!response.ok) {
                          if (response.status === 404) {
                              throw new Error('The requested resource was not found.');
                          } else {
                              throw new Error('Network response was not ok. Status: ' + response.status + ' - ' + response.statusText);
                          }
                      }
                      return response.text(); // Get the raw text of the response
                  })
                  .then(data => {
                      try {
                          var jsonData = JSON.parse(data); // Try to parse the JSON
                          var oModel = new JSONModel(jsonData);
                          this.getView().setModel(oModel, "sqliteData");
                      } catch (error) {
                          // If parsing fails, show an error message
                          MessageToast.show("Error parsing JSON data: " + error.message);
                      }
                  })
                  .catch(error => {
                        // Handle network errors and specific error cases
                        MessageToast.show("Error fetching data: " + error.message);
                  });
          }

        });
    });

//View1.view.xml

<mvc:View controllerName="ui5sql.ui5sql.controller.View1" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m">
    <Page id="page" title="{i18n>title}">
        <content>
          <!-- Your UI controls go here -->
          <Button text="Fetch Data" press="fetchDataFromNodeServer" />
          <Table items="{/}">
            <columns>
              <Column>
                <Text text="Column 1" />
              </Column>
              <!-- Add more columns as needed -->
            </columns>
            <items>
              <ColumnListItem>
                <cells>
                  <Text text="{Property1}" />
                  <!-- Bind more properties as needed -->
                </cells>
              </ColumnListItem>
            </items>
          </Table>
        </content>
    </Page>
</mvc:View>

In Console getting this strange error
-language=EN:1
Failed to load resource: the server responded with a status of 404 (Not Found)
Log-dbg.js:499 2024-04-24 22:20:02.938600 Connector (LrepConnector) failed call ‘loadFlexData’: Error: Not Found
Application startup continues without data from this storage. –

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật