import React, { useEffect, useState } from "react";
const Test = () => {
useEffect(() => {
let url = "http://127.0.0.1:8000"
fetch(url)
.then(res => res.text())
.then(res => {
document.getElementById("content").innerHTML = res;
})
}, [])
return (
<div id="content">
</div>
)
}
export default Test;
My backend code what am giving in response
<!DOCTYPE html>
<html>
<head>
{% load static %}
<meta charset="utf-8"/>
<title> Velodrivers </title>
</head>
<body>
<div>
<canvas id="output"></canvas>
<video id="video" playsinline style="
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
visibility: hidden;
width: auto;
height: auto;
">
</video>
</div>
<div>
<label for="color"> Color {{ pallet }} </label>
<input id="color" type="color" value="" />
<label for="opacity"> Strength </label>
<input id="opacity" type="range" min="0" max="1" step="0.01"/>
</div>
</body>
<script src='{% static "main.js" %}'></script>
</html>
My backend returns response as a html element which contains html css and javascript. from react i am making the api call and getting the html content as well as add to innerHTML. But the javascript functionality is not working.
The backend html code opens webcam that is not working here because thatopens using javascript.
Please take a look how can i make it work.