How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?

I am using $ wpdb to do a mysql query and get the data from a php file.

$  results = $  wpdb->get_results("SELECT * FROM table_name");  

Now, I have registered a Gutenberg block with the wordpress api..

the component is a .js file, which uses (WordPress React) under the hood:

import { registerBlockType } from "@wordpress/blocks"; import { __ } from "@wordpress/i18n"; import edit from "./pruefungenEdit";  registerBlockType("mytheme-blocks/pruefungen", {     title: __("Pruefungen Block", "mytheme-blocks"),     description: __("Display a Table of exams", "mytheme-blocks"),     category: "mytheme-category",     icon: {         background: "#f03",         foreground: "#fff",         src: "dashicons-database",     },     keywords: [__("pruefungenBlock", "mytheme-blocks")],     edit: edit,     save: () => {         return <p>Test</p>;     }, }); 

This is my React component that I use for above edit() function:

import { Component } from "@wordpress/element"; import { withSelect } from "@wordpress/data"; import { __ } from "@wordpress/i18n";  class PruefungenEdit extends Component {      render() {         //where to get the data from the query in .php file??         return <div>Data...</div>;     } }  export default PruefungenEdit; 

I can’t use php code obviously inside my .js react file.. I thought about setting up a small nodejs server that queries my localhost mysql table, and send that data via custom api route. THen I query that route on my react frontend and display the data… but that looks like too much workaround to me, I mean php is itself some kind of backend, does WordPress not offer that possibility to query mysql data and send it to the frontend somehow?

My question now is, how do I get the data from the php file into my gutenberg Block that I registered for the block editor frontend?