Back-end data preview in Front-End

fetch('/save-feedback', requestOptions)
    .then(
        res => res.json()
    ).then(
        data => {
            // setProductData(data)
            console.log("fetch data", data.feedbackType);
            // console.log(productData)
        }
    )

The above code is for getting the data from Backend and
I want to know how to preview the output on the Website

Why is this Javascript file not loaded?

On my React/Node site, I try to embed some Javascript that is hosted on a different domain:

<div id="example_hype_container" style="overflow: hidden;">
    <script type="text/javascript" charset="utf-8" 
          src="https://adifferent.com/wp-content/uploads/hype/one/example_hype_generated_script.js?44322">
    </script>
</div>

However, the animation that this Javascript is supposed to generate does not show up. It just shows the div as blank space. There are no errors in the console.

When I look under the Network tab in Chrome, the JS file is not listed there. What could be the reason? I mean, shouldn’t it be listed there, even if for example for some CORS reason it was blocking the JS file?

What could be the reason the JS code doesn’t seem to be processed?
Besides CORS, the only other reason I could come up with, is a sanitizer I use. But turning that off, also makes no difference.

P.S. When I embed the same code on another site, just as a html file, is works.

Tell me what line i can add to this code so that it can redirect to another page in javascript?

This redirects to new page specified always the form is submitted either by validation is confirmed or without. I want it to be redirected after it is confirmed. Help me out with this

<form name="studentDetails" onsubmit="validate()" method="POST" action="successRegistration.html">
            <table>
                <tr>
                    <td><label for="name">Student Name&colon;</label></td>
                    <td><input type="text" id="name"/></td>
                </tr>
                <tr>
                    <td><label for="password">Student Password&colon;</label></td>
                    <td><input type="password" id="password"/></td>
                </tr>
                <tr>
                    <td><label for="age">Student Age&colon;</label></td>
                    <td><input type="text" id="age" minlength="2" maxlength="2"/></td>
                </tr>
                <tr>
                    <td><label for="gender">Gender&colon;</label></td>
                    <td><input type="radio" name="gender" id="gender" value="M"/>Male</td>
                    <td><input type="radio" name="gender" id="gender" value="F"/>Female</td>
                </tr>
            </table><br/>
            <input type="submit" value="Register"/>
        </form>

How to save or pass the variable in binded function in on press in a component which is return after pushing in loop in react native?

im getting this.

 LOG  {"_dispatchInstances": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": [FiberNode], "_debugSource": [Object], "actualDuration": 0.5446140170097351, "actualStartTime": 180995068.371205, "alternate": [FiberNode], "child": [FiberNode], "childLanes": 0, "deletions": null, "dependencies": null, "elementType": [Object], "flags": 1, "index": 0, "key": null, "lanes": 0, "memoizedProps": [Object], "memoizedState": null, "mode": 2, "pendingProps": [Object], "ref": [Object], "return": [FiberNode], "selfBaseDuration": 0.2353070080280304, "sibling": null, "stateNode": null, "subtreeFlags": 5, "tag": 11, "treeBaseDuration": 1.0265399813652039, "type": [Object], "updateQueue": null}, "_debugSource": {"columnNumber": 7, "fileName": "C:\Users\dell\Documents\GitHub\DressUpm\node_modules\react-native\Libraries\Components\View\View.js", "lineNumber": 32}, "actualDuration": 0.23176899552345276, "actualStartTime": 180995068.676513, "alternate": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": [FiberNode], "_debugSource": [Object], "actualDuration": 0.3187679946422577, "actualStartTime": 180995109.337359, "alternate": [Circular], "child": [FiberNode], "childLanes": 0, "deletions": null, "dependencies": null, "elementType": "RCTView", "flags": 4, "index": 0, "key": null, "lanes": 0, "memoizedProps": [Object], "memoizedState": null, "mode": 2, "pendingProps": [Object], "ref": [Object], "return": [FiberNode], "selfBaseDuration": 0.15715399384498596, "sibling": null, "stateNode": [ReactNativeFiberHostComponent], "subtreeFlags": 1, "tag": 5, "treeBaseDuration": 0.8043089509010315, "type": "RCTView", "updateQueue": null}, "child": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": [FiberNode], "_debugSource": [Object], "actualDuration": 0.016692012548446655, "actualStartTime": 180995068.801282, "alternate": [FiberNode], "child": [FiberNode], "childLanes": 0, "deletions": null, "dependencies": null, "elementType": [Object], "flags": 0, "index": 0, "key": "2", "lanes": 0, "memoizedProps": [Object], "memoizedState": null, "mode": 2, "pendingProps": [Object], "ref": null, "return": [Circular], "selfBaseDuration": 0.2726159989833832, "sibling": [FiberNode], "stateNode": null, "subtreeFlags": 0, "tag": 11, "treeBaseDuration": 0.563770979642868, "type": [Object], "updateQueue": null}, "childLanes": 0, "deletions": null, "dependencies": null, "elementType": "RCTView", "flags": 4, "index": 0, "key": null, "lanes": 0, "memoizedProps": {"accessibilityState": undefined, "accessible": true, "children": [Array], "collapsable": false, "focusable": true, "hitSlop": undefined, "onBlur": [Function onBlur], "onClick": [Function onClick], "onFocus": [Function onFocus], "onResponderGrant": [Function onResponderGrant], "onResponderMove": [Function onResponderMove], "onResponderRelease": [Function onResponderRelease], "onResponderTerminate": [Function onResponderTerminate], "onResponderTerminationRequest": [Function onResponderTerminationRequest], "onStartShouldSetResponder": [Function onStartShouldSetResponder], "style": [Array]}, "memoizedState": null, "mode": 2, "pendingProps": {"accessibilityState": undefined, "accessible": true, "children": [Array], "collapsable": false, "focusable": true, "hitSlop": undefined, "onBlur": [Function onBlur], "onClick": [Function onClick], "onFocus": [Function onFocus], "onResponderGrant": [Function onResponderGrant], "onResponderMove": [Function onResponderMove], "onResponderRelease": [Function onResponderRelease], "onResponderTerminate": [Function onResponderTerminate], "onResponderTerminationRequest": [Function onResponderTerminationRequest], "onStartShouldSetResponder": [Function onStartShouldSetResponder], "style": [Array]}, "ref": {"current": [ReactNativeFiberHostComponent]}, "return": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": [FiberNode], "_debugSource": [Object], "actualDuration": 0.30084601044654846, "actualStartTime": 180995068.616205, "alternate": [FiberNode], "child": [Circular], "childLanes": 0, "deletions": null, "dependencies": null, "elementType": [Object], "flags": 0, "index": 0, "key": null, "lanes": 0, "memoizedProps": [Object], "memoizedState": null, "mode": 2, "pendingProps": [Object], "ref": null, "return": [FiberNode], "selfBaseDuration": 0.05177000164985657, "sibling": null, "stateNode": null, "subtreeFlags": 5, "tag": 10, "treeBaseDuration": 0.7912329733371735, "type": [Object], "updateQueue": null}, "selfBaseDuration": 0.11538398265838623, "sibling": null, "stateNode": {"_children": [Array], "_internalFiberInstanceHandleDEV": [Circular], "_nativeTag": 4667, "viewConfig": [Object]}, "subtreeFlags": 1, "tag": 5, "treeBaseDuration": 0.7394629716873169, "type": "RCTView", "updateQueue": null}, "_dispatchListeners": [Function onResponderRelease], "_targetInst": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": [FiberNode], "_debugSource": [Object], "actualDuration": 0.5446140170097351, "actualStartTime": 180995068.371205, "alternate": [FiberNode], "child": [FiberNode], "childLanes": 0, "deletions": null, "dependencies": null, "elementType": [Object], "flags": 1, "index": 0, "key": null, "lanes": 0, "memoizedProps": [Object], "memoizedState": null, "mode": 2, "pendingProps": [Object], "ref": [Object], "return": [FiberNode], "selfBaseDuration": 0.2353070080280304, "sibling": null, "stateNode": null, "subtreeFlags": 5, "tag": 11, "treeBaseDuration": 1.0265399813652039, "type": [Object], "updateQueue": null}, "_debugSource": {"columnNumber": 7, "fileName": "C:\Users\dell\Documents\GitHub\DressUpm\node_modules\react-native\Libraries\Components\View\View.js", "lineNumber": 32}, "actualDuration": 0.23176899552345276, "actualStartTime": 180995068.676513, "alternate": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": [FiberNode], "_debugSource": [Object], "actualDuration": 0.3187679946422577, "actualStartTime": 180995109.337359, "alternate": [Circular], "child": [FiberNode], "childLanes": 0, "deletions": null, "dependencies": null, "elementType": "RCTView", "flags": 4, "index": 0, "key": null, "lanes": 0, "memoizedProps": [Object], "memoizedState": null, "mode": 2, "pendingProps": [Object], "ref": [Object], "return": [FiberNode], "selfBaseDuration": 0.15715399384498596, "sibling": null, "stateNode": [ReactNativeFiberHostComponent], "subtreeFlags": 1, "tag": 5, "treeBaseDuration": 0.8043089509010315, "type": "RCTView", "updateQueue": null}, "child": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": [FiberNode], "_debugSource": [Object], "actualDuration": 0.016692012548446655, "actualStartTime": 180995068.801282, "alternate": [FiberNode], "child": [FiberNode], "childLanes": 0, "deletions": null, "dependencies": null, "elementType": [Object], "flags": 0, "index": 0, "key": "2", "lanes": 0, "memoizedProps": [Object], "memoizedState": null, "mode": 2, "pendingProps": [Object], "ref": null, "return": [Circular], "selfBaseDuration": 0.2726159989833832, "sibling": [FiberNode], "stateNode": null, "subtreeFlags": 0, "tag": 11, "treeBaseDuration": 0.563770979642868, "type": [Object], "updateQueue": null}, "childLanes": 0, "deletions": null, "dependencies": null, "elementType": "RCTView", "flags": 4, "index": 0, "key": null, "lanes": 0, "memoizedProps": {"accessibilityState": undefined, "accessible": true, "children": [Array], "collapsable": false, "focusable": true, "hitSlop": undefined, "onBlur": [Function onBlur], "onClick": [Function onClick], "onFocus": [Function onFocus], "onResponderGrant": [Function onResponderGrant], "onResponderMove": [Function onResponderMove], "onResponderRelease": [Function onResponderRelease], "onResponderTerminate": [Function onResponderTerminate], "onResponderTerminationRequest": [Function onResponderTerminationRequest], "onStartShouldSetResponder": [Function onStartShouldSetResponder], "style": [Array]}, "memoizedState": null, "mode": 2, "pendingProps": {"accessibilityState": undefined, "accessible": true, "children": [Array], "collapsable": false, "focusable": true, "hitSlop": undefined, "onBlur": [Function onBlur], "onClick": [Function onClick], "onFocus": [Function onFocus], "onResponderGrant": [Function onResponderGrant], "onResponderMove": [Function onResponderMove], "onResponderRelease": [Function onResponderRelease], "onResponderTerminate": [Function onResponderTerminate], "onResponderTerminationRequest": [Function onResponderTerminationRequest], "onStartShouldSetResponder": [Function onStartShouldSetResponder], "style": [Array]}, "ref": {"current": [ReactNativeFiberHostComponent]}, "return": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": [FiberNode], "_debugSource": [Object], "actualDuration": 0.30084601044654846, "actualStartTime": 180995068.616205, "alternate": [FiberNode], "child": [Circular], "childLanes": 0, "deletions": null, "dependencies": null, "elementType": [Object], "flags": 0, "index": 0, "key": null, "lanes": 0, "memoizedProps": [Object], "memoizedState": null, "mode": 2, "pendingProps": [Object], "ref": null, "return": [FiberNode], "selfBaseDuration": 0.05177000164985657, "sibling": null, "stateNode": null, "subtreeFlags": 5, "tag": 10, "treeBaseDuration": 0.7912329733371735, "type": [Object], "updateQueue": null}, "selfBaseDuration": 0.11538398265838623, "sibling": null, "stateNode": {"_children": [Array], "_internalFiberInstanceHandleDEV": [Circular], "_nativeTag": 4667, "viewConfig": [Object]}, "subtreeFlags": 1, "tag": 5, "treeBaseDuration": 0.7394629716873169, "type": "RCTView", "updateQueue": null}, "bubbles": undefined, "cancelable": undefined, "currentTarget": {"_children": [[ReactNativeFiberHostComponent]], "_internalFiberInstanceHandleDEV": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": [FiberNode], "_debugSource": [Object], "actualDuration": 0.23176899552345276, "actualStartTime": 180995068.676513, "alternate": [FiberNode], "child": [FiberNode], "childLanes": 0, "deletions": null, "dependencies": null, "elementType": "RCTView", "flags": 4, "index": 0, "key": null, "lanes": 0, "memoizedProps": [Object], "memoizedState": null, "mode": 2, "pendingProps": [Object], "ref": [Object], "return": [FiberNode], "selfBaseDuration": 0.11538398265838623, "sibling": null, "stateNode": [Circular], "subtreeFlags": 1, "tag": 5, "treeBaseDuration": 0.7394629716873169, "type": "RCTView", "updateQueue": null}, "_nativeTag": 4667, "viewConfig": {"Commands": [Object], "NativeProps": [Object], "bubblingEventTypes": undefined, "directEventTypes": [Object], "uiViewClassName": "RCTView", "validAttributes": [Object]}}, "defaultPrevented": undefined, "dispatchConfig": {"dependencies": ["topTouchCancel", "topTouchEnd"], "registrationName": "onResponderRelease"}, "eventPhase": undefined, "isDefaultPrevented": [Function functionThatReturnsFalse], "isPersistent": [Function functionThatReturnsTrue], "isPropagationStopped": [Function functionThatReturnsFalse], "isTrusted": undefined, "nativeEvent": {"changedTouches": [[Circular]], "identifier": 0, "locationX": 36.435508728027344, "locationY": 60.07415771484375, "pageX": 46.435508728027344, "pageY": 545.0741577148438, "target": 4665, "targetSurface": -1, "timestamp": 1649496640240, "touches": []}, "target": {"_children": [], "_internalFiberInstanceHandleDEV": {"_debugHookTypes": null, "_debugNeedsRemount": false, "_debugOwner": [FiberNode], "_debugSource": [Object], "actualDuration": 3.2463849782943726, "actualStartTime": 180993717.489128, "alternate": null, "child": null, "childLanes": 0, "deletions": null, "dependencies": null, "elementType": "RCTImageView", "flags": 0, "index": 0, "key": null, "lanes": 0, "memoizedProps": [Object], "memoizedState": null, "mode": 2, "pendingProps": [Object], "ref": null, "return": [FiberNode], "selfBaseDuration": 0.047922998666763306, "sibling": null, "stateNode": [Circular], "subtreeFlags": 0, "tag": 5, "treeBaseDuration": 0.047922998666763306, "type": "RCTImageView", "updateQueue": null}, "_nativeTag": 4665, "viewConfig": {"NativeProps": [Object], "bubblingEventTypes": undefined, "directEventTypes": [Object], "uiViewClassName": "RCTImageView", "validAttributes": [Object]}}, "timeStamp": 1649496640248, "touchHistory": {"indexOfSingleActiveTouch": 0, "mostRecentTimeStamp": 1649496640240, "numberActiveTouches": 0, "touchBank": [[Object]]}, "type": undefined}

from this code.

 ```
    function abc(filename)
{
  console.log(filename);
}

function bottomLayer(fileNames) 
{
  var items=[];
  for (var i=0;i<fileNames.length;i++)
  {
    items.push(
    <Pressable key={i+2} style={({ pressed }) => [{ height: pressed ? 100 : 70, width: pressed ? 100 : 90, paddingLeft:10,alignSelf:'flex-end', paddingRight:10}]} 
    onPress={abc.bind(fileNames[i])}>
      <Image key={i+2} style={styles.pic} source={{uri:"file://"+RNFS.ExternalDirectoryPath+'/'+fileNames[i]}} />
    </Pressable>
    );
  }
  if(fileNames.length==0)
  {
    items.push(
    <Pressable key={0} style={({ pressed }) => [{ height: pressed ? 100 : 70, width: pressed ? 100 : 90, paddingLeft:10, paddingRight:10 }]} onPress={()=>{correctPressFunction(shirtIsPress?1:(jeansIsPress?2:3),"")}}>
      <Image key={i+2} style={styles.pic} source={sample} />
    </Pressable>
    );
  }
  return items;
}
    ```

i want to send the filenames[i] to the binded function abc when Pressable is pressed. But what im getting is undefined. i want to get its value but it seems rather it is not saved or should i say it does not stay there.

How to save a Javascript array as a .txt file

Good day all.

the following code quite easily saves the “const rows” array as a .txt file

///

function exportAdjacency() {

        const rows = [
            [-1, 183, 294, -1],
            [183, -1, 171, 306],
            [294, 171, -1, 187],
            [-1, 306, 187, -1]
        ];


        const csvContent = `data:text/csv;charset=utf-8,${rows
            .map((e) => e.join(","))
            .join("n")}`;
        const encodedUri = encodeURI(csvContent);
        const link = document.createElement("a");
        link.setAttribute("href", encodedUri);
        link.setAttribute("download", "data.txt");
        document.body.appendChild(link);
        link.click()
    }

//

However, in my case, my array is not formatted as in the code above. In fact, I have a 1 D array of, in this case, 16 numbers, which I need to feed into the above code.

I have tried to segment the array using array.slice as below

//

function func() {

        var article = [1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16];

        var heading = article.slice(0, 4);
        var heading2 = article.slice(4, 8);
        var heading3 = article.slice(8, 12);
        var heading4 = article.slice(12, 16);
    
    alert(heading)
    alert(heading2)
    alert(heading3)
    alert(heading4)
        
    }

//

The alerts just confirm that the segmentation was successful.

My question is, how do I segment the 1 D array and feed its contents into the

“const rows” of the first code example?

I have tried changing the first code snippet to rather accept something like

“array rows” but this doesn’t work.

Now in this example, the 1 D array has 16 elements. In the general case, it could have any number of elements.

Any help would be greatly appreciated.

Thanks

Paul

Vue router get full path based on nested route

I created nested routes for vue router, and I am using that routes for data to create navigation menu. And for the ‘router-link :to=’ i am currently using route.path. Issue with that is that that is only part of the path and want to put absolute path that includes parents paths aswell. Is there some way to do this. I also tried to iterate over all routes and to set some property that will include parent paths, but i couldnt write good function.

{ path:'/meteorologija', name:'meteorologija', component:()=>import('../pages/BlogPage'), children:[
        { 
            path:'/meteorolosko-bdenje', name:'meteorolosko bdenje', component:()=>import('../pages/BlogPage'), 
            children:[
                { path:'/aktuelni-podaci', name:'aktuelni podaci', component:()=>import('../pages/BlogPage'),
                    children:[
                        { path:'/podaci', name:'Podaci', component:()=>import('../pages/BlogPage') },
                        { path:'/trenutne-temerature', name:'Trenutne temperature', component:()=>import('../pages/BlogPage') },  
                        { path:'/ekstremne-temperature', name:'Ekstremne Temperature', component:()=>import('../pages/BlogPage') },  
                        { path:'/pritisak', name:'Pritisak', component:()=>import('../pages/BlogPage') },  
                        { path:'/vjetar', name:'Vjetar', component:()=>import('../pages/BlogPage') },  
                        { path:'/kolicina-padavina', name:'Kolicina padavina', component:()=>import('../pages/BlogPage') },  
                        { path:'/radarska-slika', name:'Radarska Slika', component:()=>import('../pages/BlogPage') },  


                    ] 
                },

This is the function that i am trying to write that will get path of deeply nested object that includes paths of all parent objects

 t(routes, path={}){
       routes.forEach((r,i)=>{
          if(r.children){
              // path+= r.path;
              this.t(r.children, path);
          }
       });

Can state be named differently (with another name like ‘globalState’) in ReactJS?

I am new to React (just 1 online course) and am discovering the magic of props and state. I realise that props are immutable and state is mutable. I am getting clearer about their uses but there’s one point I would like to clarify that I have not been able to find online.

So props can be passed from Parent to Child and when they are passed the name of the variable holding the props can be changed. When state or its values are passed to child components, a mechanism is also passed along to the child to be able to modify the state at the parent level by the child.

I hope this is correct as so far this is what I have understood about props and state.

Now I have a project where I have “App.js” which is the topmost parent with “Home.js” as its child. I plan to use state in both of them. But the state in App.js is something of a global state (and I don’t want to use redux) and the state in Home.js would be the state that the application would use for its regular use.

Now both of them are being named using the state={} format (I am using class based components) and referred to as this.state but within their own components, which is working fine.

My question is about the format of naming state as state, is this mandatory or just a standard that developers are expected to follow?

I’ve tried to change the name of the state and it seemed to work but maybe I did something wrong as I didn’t really expect it to work… so that’s why I wanted to confirm if it’s ok to change the name of state in a component to something like globalState or store

Any advise would be appreciated.

Split a String by a Regex in JavaScript

I have the string “Vl.55.16b25.3d.42b50.59b30.90.24b35.3d.56.67b70.Tv.54b30.Vl.41b35.Tv.Bd.71b50.3d.99b20.03b50.Tv.73b50.Vl.05b25.12b40.Bd.Tv.82b25.”
How to detached get results like:
[“Vl.55.16b25”, 3d.42.b50.59b30.90.24b35, 3d.56.67b70, …]

The logic.
Condition 1: The End will be start b and 2 number. Example: b20, b25.
If pass condition 1 I need to check condition 2.
Condition 2 maybe like “3d” or 2 characters. If don’t match condition 2 we need to pass the next character to the current block.
Many thanks.

Is it possible to get JetBrains-style debug-time line hints in Ace Editor?

I currently have ace editor embedded in my browser. I’d like to use line hints when i run code in thr browser application. Does ace offer any such functionality, or would it be advicable to add and delete comments at the end of the line? note that I only want a single character in these hints. I also considered using the gutter in my application, but line numbers are important to me as well

enter image description here

here’s an image of my application

enter image description here

I would like to have ~F appear on the green line, and ~D appear on the blue line. This is a RISC ISA executing, but I don’t think that should matter.

On canvas, scale shape from its center

I have a circle at [x, y] with a radius r. I want to scale it by x1.1, while keeping it at the same [x, y] position. I tried suggested code from other questions but I just couldn’t do it.

Here is my code:

ctx.save();
ctx.translate(x, y);
ctx.scale(1.1, 1.1);

ctx.beginPath();
ctx.arc(x, y, r, 0, 2 * Math.PI);
ctx.fillStyle = '#000000';
ctx.fill();

ctx.restore();

Any suggestions? Thanks.

How can I add Google Tag Manager to chrome extension content-scripts?

I have a chrome extension that activates on some websites and injects some elements in html DOM. Now I want to add Google Tag Manager on the extension.

In the Google Tag Manager documents it’s mentioned to add the given function in the page <head> tag. So first I tried to add the script tag in document <head> tag as soon as the extension is loaded:

const loadGTM = () => {
  const scriptTag = document.createElement("script");
  scriptTag.innerHTML = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
  new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
  'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  })(window,document,'script','dataLayer','GTM-XXXXXXX');`;
  document.head.appendChild(scriptTag);

  const noScriptTag = document.createElement("noscript");
  noScriptTag.innerHTML = `<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
  height="0" width="0" style="display:none;visibility:hidden"></iframe>`;
  document.body.prepend(noScriptTag);
}

Then I tried to connect through Google Tag Assistant and it didn’t.

After this I tried to run the script instead of adding the script to head tag. So I open a new gtm.js file and added the script in it:

//gtm.js
const accountToken = `GTM-XXXXXXX`;
function integrateGTM() {
  (function (w, d, s, l, i) {
    w[l] = w[l] || [];
    w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });
    var f = d.getElementsByTagName(s)[0],
      j = d.createElement(s),
      dl = l != "dataLayer" ? "&l=" + l : "";
    j.async = true;
    j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
    f.parentNode.insertBefore(j, f);
  })(window, document, "script", "dataLayer", accountToken);
  const code = `<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${accountToken}"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>`;
  const bodyScript = document.createElement("noscript");
  bodyScript.innerHTML = code;
  document.body.prepend(bodyScript);
}

integrateGTM();

And again after trying to connect through Tag Assistant it doesn’t connect.

So If anybody has any idea or experience in this field I would be glad to get some help.
Thank you!