How to enable bulk amount of option values in html selection drop down box?

Does anyone know a way to enable all the times in this selection box without having to go through them with “document.getElementById”. There are about 30 of these, for all the times.

In the live code, the option values (times) can be disabled depending on a date selection, so at the start of the function (onchange event) it enables them all for use again (and disables per date selected).

<select name="time" id="time">
<option value="N/A">Select</option>
<option value="12:00pm" id="12:00pm">12:00pm</option>
<option value="12:15pm" id="12:15pm">12:15pm</option>
<option value="12:30pm" id="12:30pm">12:30pm</option>
<option value="12:45pm" id="12:45pm">12:45pm</option>
<option value="13:00pm" id="13:00pm">13:00pm</option>
<option value="13:15pm" id="13:15pm">13:15pm</option>
<option value="13:30pm" id="13:30pm">13:30pm</option>
<option value="13:45pm" id="13:45pm">13:45pm</option>
<option value="14:00pm" id="14:00pm">14:00pm</option>
</select>

<script>
var select = document.getElementById('date');
select.onchange = SetClosed;
window.onload = SetClosed;

function SetClosed(){
document.getElementById("12:00pm").disabled = false;
document.getElementById("12:15pm").disabled = false;
document.getElementById("12:30pm").disabled = false;
document.getElementById("12:45pm").disabled = false;
document.getElementById("13:00pm").disabled = false;
document.getElementById("13:15pm").disabled = false;
document.getElementById("13:30pm").disabled = false;
document.getElementById("13:45pm").disabled = false;
document.getElementById("14:00pm").disabled = false;
}
</script>

i have tried this to replace the large amounts of “getElementById”, but no joy:

document.querySelectorAll('input[name="time"]').forEach(element => {element.removeAttribute("disabled");});

The code works using ID’s of course, but was hoping there could be a way to reduce the code down a bit.

YAML multi line scalars in JSON.stringify with TypeScript

I have a YAML document I’m trying to convert to Pulumi which makes liberal use of multi-line scalar values. Here’s an example:

apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: azure-secrets
spec:
  provider: azure
  parameters:
    usePodIdentity: "false"
    keyvaultName: "kvname"
    cloudName: ""
    objects:  |
      array:
        - |
          objectName: secret1
          objectType: secret                    # object types: secret, key or cert
    tenantId: "tid"

Note the usage of scalars and a nested yaml pattern for the objects key.

I’m currently manually constructing this pattern like so:

objects: `array:n  - |n    objectName: $CERT_NAMEn    objectType: secretn`,

Which will manually build the correct YAML format, but I’d like to use JSON.stringify to construct this instead so I don’t have to manually build the strings. Is there a way to do it?

How to run a script outside the src folder in react?

My directory is as such:

├Script.js
|
├public/
|     └...
└src/
   └ App.js

and inside App.js I’m trying to invoke the Script.js as such:

import calculations from './../Script' 

...

onclick={()=>{calculations()}}

Script.js:

const calculations=()=>{...}

export default calculations;

but obviously it won’t work, so how do I run a script on the server?
do I make a post request to the server? If so, how do I handle it? (like in express app.post())

I want to run a JavaScript code synchronously in react native

I’m working in a project where I retrieve data from local database using SQLite then I process the data and finally I use the processed data in a calculation method.

The problem is that the code is running asynchronously so when I call the calculation method in the first time it works before the retrieve and processing methods it only works in the second or third run.

I have 4 retrieve methods :

    retrieve1();
    retrieve2();
    retrieve3();
    retrieve4();

then I want to process the retrieved data so I have the following methods:

processRetrieve1();
processRetrieve2();
processRetrieve3();
processRetrieve4();

finally I want to call the calculation method:

Calculate();

How can I run this code in the following order?
Retrieve methods -> Processing methods -> Calculating method

How to merge 2 objects based on a property value to create new object?

Please see raw dataset below:

[
    {
        "date": "2021-12-03",
        "minutes": 132.00001,
        "category": "RSVR"
    },
    {
        "date": "2021-12-03",
        "minutes": 4.95,
        "category": "DMND"
    },
    {
        "date": "2021-12-03",
        "minutes": 127.03218,
        "category": "SLIP"
    },
    {
        "date": "2021-12-04",
        "minutes": 113.97533,
        "category": "SLIP"
    },
    {
        "date": "2021-12-04",
        "minutes": 11.55,
        "category": "DMND"
    },
    {
        "date": "2021-12-04",
        "minutes": 105.30001,
        "category": "RSVR"
    }
]

Expected:
would like generate new array where:

  • objects with category: 'DMND' are added as it is
  • new object is created using structure (example of new object provided below):
    • {
        date: unique date from the objects with  category: 'RSVR' and category: 'SLIP'
        minutes: add minutes from category: 'RSVR' and category: 'SLIP'
        category: 'SPLY'
      }
      
      Example
      
      {
        "date": "2021-12-03",
        "minutes": 132.00001,
        "category": "RSVR"                                 {
      },                                                     "date": "2021-12-03",
      {                                            =         "minutes": 259.03219,
        "date": "2021-12-03",                                "category": "SPLY"
        "minutes": 127.03218,                              }
        "category": "SLIP"
      }
      

    (basically merging 2 objects with category: 'RSVR' and category: 'SLIP' by adding their minutes to create a new object and add that new object to the array)

New array will look like this:
[
    {
        "date": "2021-12-03",
        "minutes": 4.95,
        "category": "DMND"
    },
    {
        "date": "2021-12-03",
        "minutes": 259.03219,
        "category": "SPLY"
    },
    {
        "date": "2021-12-04",
        "minutes": 11.55,
        "category": "DMND"
    },
    {
        "date": "2021-12-04",
        "minutes": 219.275331,
        "category": "SPLY"
    }
]

Not quite sure how to go about doing this yet. any help would be appreciated

How to add anchors to url based on which project in viewport

How can I add / change the #anchor in the url depending on to which project I scrolled?

So, when I scroll over the projects on my one-pager, I want the URL to change dynamically:

www.likethis.com#project-1
www.likethis.com#project-2
www.likethis.com#project-3

In the end, I want to be able to share URLs which link directly to projects on the page.

Everything I found so far is something like “data-url” or setting an article to “active”?

nested select option php mysql jquery

I have an edit form modal with 3 input : name(text), category(select option), subcategory(select option)

I want the subcategory options updated when the category selection is changed. I have done this nested select option on the modal add before, and it works. But it doesn’t work when I’m trying to do the same at the edit modal. The Subcategory select option only displaying the subcategory’s value of the first row when I clicked the first row edit button. When I clicked the other row’s edit button, the subcategory select option in the form didn’t show anything.

On the add modal, I’m using jquery to set the subcategory value when category changed using .change event and make a request to get the subcategory data then I add and also set the id and the text from the subcategory data. Is there a way so the list of subcategory’s option in the edit form modal could be changed by the selected category? And should it using JS or there is any other simple way?

Here is the code

<!-- Table & Modal-->
<div class="table-responsive">
  <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
    <thead>
      <tr>
        <th>No</th>
        <th>Name</th>
        <th>Category</th>
        <th>Subcategory</th>
        <th>Action</th>
      </tr>
    </thead>
    <tbody>
      <?php $ambilsemuadatastock = mysqli_query($conn, "SELECT n.idname, n.name, c.category, sc.category AS subcategory from name b JOIN category k ON n.idcategory = c.idcategory JOIN category sk ON n.idsubcategory=sc.idcategory");
      $i = 1;
      while ($data = mysqli_fetch_array($ambilsemuadatastock)) {
        $idname = $data['idname'];
        $name = $data['name'];
        $category = $data['category'];
        $subcategory = $data['subcategory'];
      ?>

        <tr>
          <td><?php echo $i++; ?></td>
          <td><?php echo $name; ?></td>
          <td><?php echo $category; ?></td>
          <td><?php echo $subcategory; ?></td>
          <td>
            <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#edit<?= $idname; ?>">Edit</button>
            <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#delete<?= $idname; ?>">Delete</button>
          </td>
        </tr>

        <!-- The Edit Modal -->
        <div class="modal fade modal-editname" id="edit<?= $idname; ?>">
          <div class="modal-dialog">
            <div class="modal-content">

              <!-- Modal Header -->
              <div class="modal-header">
                <h4 class="modal-title">Edit</h4>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
              </div>

              <!-- Modal body -->
              <form method="POST">
                <div class="modal-body">
                  <?php
                  $allcategory = mysqli_query($conn, "SELECT * FROM category WHERE parentcategory = 0");

                  $getdtname = mysqli_query($conn, "SELECT n.idname, n.name, n.idcategory, c.category, n.idsubcategory, sc.category AS subcategory, n.stock from name b JOIN category k ON n.idcategory = c.idcategory JOIN category sk ON n.idsubcategory=sc.idcategory WHERE idname = ('$idname')");

                  while ($dtname = mysqli_fetch_array($getdtname)) {
                  ?>
                    <input type="text" id="nameedit" name="name" value="<?= $dtname['name']?>" class="form-control" required>
                    <br>
                    <select class="form-control" id="selopcatedit" name="category">
                      <?php foreach ($allcategory as $cat) { ?>
                        <option <?php if ($cat['idcategory'] == $dtname['idcategory']) {
                                  echo "selected="selected"";
                                } ?> value="<?= $cat['idcategory']; ?>">
                          <?= $cat['category']; ?>
                        </option>
                      <?php } ?>
                    </select>
                    <br>
                    <select class="form-control" id="selopsubcatedit" name="subcategory">
                      <option value="">Choose Subcategory</option>
                    </select>
                    <br>
                    <input type="hidden" id="idnameedit" name="idname" value="<?= $dtname['name']?>">
                  <?php
                  }
                  ?>
                  <button type="submit" class="btn btn-primary" name="updatename">Edit</button>
                </div>
              </form>

            </div>
          </div>
        </div>
      <?php
      }
      ?>

    </tbody>
  </table>
</div>

Here is the JS

<!-- JS -->
<script>
  $("#selopcatedit").change(function() {
    var parentcat = $(this).val();
    console.log(parentcat);

    $.ajax({
      url: 'getCatValue.php',
      type: 'post',
      data: {
        parentcat: parentcat
      },
      dataType: 'json',
      success: function(response) {
        var len = response.length;
        console.log(response);

        $("#selopsubcatedit").empty();
        for (var i = 0; i < len; i++) {
          var idcategory = response[i]['idcategory'];
          var category = response[i]['category'];

          $("#selopsubcatedit").append("<option value='" + idcategory + "'>" + category + "</option>");
        }
      },
      error: function(req, err) {
        console.log('my message : ' + err);
      }
    });
  });
</script>

I also make an event when the modal is showed, to do the same thing like the event change script above (set the subcategory’s value).

i have this error :exceeded maximum execution time (line 0)?

I call the api to search into the json based on skus ,the user will put the sku and the start time ,dthen the function will bee count how many orders we have for this sku on this day

This is my code:

// to call the page 
    function firstCall(pag,start){
    
    
      try{

    var url ='https://*****************************?Page=' + pag + '&shopId%5B%5D=90841&pageSize=250' + '&' + 'minOrderDate='+ start;
        var res =UrlFetchApp.fetch(url);
        var content = res.getContentText();
        
        var json= JSON.parse(content);
       
    var node = json.data;
    
     return node;
    
    
      }
      catch(err){
          return "Error getting data" + err;
      }
    }
    
    //to count how many order per day and per sku
    function getInven3(sKu,start){
     if(start == "")  return "!";
     start ="2021-11-17T";
    
      try{
        
    
    
          var url ='https://*********************************?shopId%5B%5D=90841&pageSize=250' + '&' + 'minOrderDate='+ start;
    
        var res = UrlFetchApp.fetch(url);
        var content = res.getContentText();
        var json = JSON.parse(content);
    
    
      var count =0 ;
      var count_tow =0 ;
    
    
      if (json.paging.TotalPages===1){
     for (var i=0; i<firstCall(1,start).length; i++) {
      if(firstCall(1,start)[i].state == 7){
      for (var j=0; j<firstCall(1,start)[i].orderItems.length; j++) {
        var node3=firstCall(1,start)[i].orderItems[j].product.sku;
    
    
     if ((node3 == sKu)) {
         
       
     count++;
    
     } 
       
     }
     
     
      }
      
     }
     return count;
        
      
    
    
      
     
    
    
      }
     else  if (json.paging.TotalPages>1)
                    {
                      console.log("2 page");
    var d=0;
    for (var x = 0, ln = json.paging.TotalPages; x < ln; x++) {
    
    
    
      d++;
      if(d<=json.paging.TotalPages){
    
                                               
                     
        for (var i=0; i<firstCall(d,start).length; i++) {
       
      
      if(firstCall(d,start)[i].state == 7){
      for (var j=0; j<firstCall(d,start)[i].orderItems.length; j++) {
        var node3=firstCall(d,start)[i].orderItems[j].product.sku;
    
      
    
     if ((node3 == sKu)) {
            
       
      count_tow++;
    
       
       
     }
     
     
      }
       
     
    
        
      }
      
      }
    
      }
     }
        return count_tow;
      }
      }
      catch(err){
          return "Error getting data" + err;
      }
    }
    

Error messages keep saying “Exceeded maximum execution time (line 0).”

Could anyone help? Thank you a lot!

Why can’t I click the hyperlinks in my card slider?

I’m trying to make a JavaScript slider which needs to work on both mobile and desktop. It should be possible to click on each and every card which should redirect me to another page.

At this moment I’ve got a working slider but I cannot click on any of the cards. This is caused by pointer-events: none; but the slider won’t work without this line.

Does anyone know how to do this right or how I can approach this in other ways?

Thanks in advance,

let slider = document.querySelector(".slider");
let innerSlider = document.querySelector(".slider-inner");

let pressed = false;
let startx;
let x;

//pc controls
slider.addEventListener("mousedown", (e) => {
  pressed = true;
  startx = e.offsetX - innerSlider.offsetLeft;
  slider.style.cursor = "grabbing";
});

slider.addEventListener("mouseevent", () => {
  slider.style.cursor = "grab";
});

slider.addEventListener("mouseup", () => {
  slider.style.cursor = "grab";
});

slider.addEventListener("mouseup", () => {
  pressed = false;
});

slider.addEventListener("mousemove", (e) => {
  if (!pressed) return;

  x = e.offsetX;
  let temp = x - startx;
  innerSlider.style.left = temp + "px";

  checkboundary();
});

function checkboundary() {
  let outer = slider.getBoundingClientRect();
  let inner = innerSlider.getBoundingClientRect();

  if (parseInt(innerSlider.style.left) > 0) {
    innerSlider.style.left = "0px";
  } else if (inner.right < outer.right) {
    let temp = inner.width - outer.width;
    innerSlider.style.left = -temp + "px";
  }
}
.componentContainer {
  display: block;
  height: 220px;
  position: relative;
  width: 1200px;
  margin: auto;
}

.slider {
  position: absolute;
  width: inherit;
  height: 150px;
  overflow: hidden;
  -webkit-touch-callout: none; 
  -webkit-user-select: none; 
  -khtml-user-select: none; 
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.slider-inner {
  position: absolute;
  top: 2px;
  left: 0;
  display: flex;
  gap: 15px;
  pointer-events: none;
  transition: 0s ease-in;
  padding: 0 5px;

}

.slider-card {
  height: 140px;
  text-align: center;
  width: 240px;
  border-radius: 10px;
  box-shadow: 0px 4px 8px #dbdbdb;
  position: relative;
}

.slider-card a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: inherit;
  position: absolute;
  width: 100%;
}
<div class="componentContainer">
    <h2>Onze promo's</h2>
    <div class="slider">
        <div class="slider-inner">
            <div class="slider-card" onclick="window.location.href='/test'">
                <a href="/test">
                    <span>test</span>
                    <span>lorem</span>
                </a>
            </div>
            <div class="slider-card">
                <a href="">
                    <span>test</span>
                    <span>lorem</span>
                </a>
            </div>
            <div class="slider-card">
                <a href="">
                    <span>test</span>
                    <span>lorem</span>
                </a>
            </div>
            <div class="slider-card">
                <a href="">
                    <span>test</span>
                    <span>lorem</span>
                </a>
            </div>
            <div class="slider-card">
                <a href="">
                    <span>test</span>
                    <span>lorem</span>
                </a>
            </div>
            <div class="slider-card">
                <a href="">
                    <span>test</span>
                    <span>lorem</span>
                </a>
            </div>
            <div class="slider-card">
                <a href="">
                    <span>test</span>
                    <span>lorem</span>
                </a>
            </div>
            <div class="slider-card">
                <a href="">
                    <span>test</span>
                    <span>lorem</span>
                </a>
            </div>
            <div class="slider-card">
                <a href="">
                    <span>test</span>
                    <span>lorem</span>
                </a>
            </div>
            <div class="slider-card">
                <a href="">
                    <span>test</span>
                    <span>lorem</span>
                </a>
            </div>
        </div>
    </div>
</div>

MongoServerError: Authentication failed when using mongo and mongo express with docker containers

I am learning docker so I was following one of the video it shown that how to connect your js app with mongoDB when it is running in docker containers . Now little variation I did is that it shown to connect mongo on system port 27017 which is default mongo port but the problem is I don’t want to connect to my system installed mongo but to the container mongo , so for that purpose I decided to run mongo container on port 3535. When I did so mongo-express successfully got connected to mongo but when I am trying to connect it with my js app(using mongoose ) it is continuously showing errors with authentication error I have checked password is correct , no brackets issue is their , the command I used to turn up my docker containers are

docker run -d -p 3535:27017 --name mongoDB --network databases -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=admin mongo

and another one for mongo-express is

docker run -d -p 8081:8081 --name mongoExp --network databases -e ME_CONFIG_BASICAUTH_USERNAME=admin -e ME_CONFIG_BASICAUTH_PASSWORD=admin -e ME_CONFIG_MONGODB_SERVER=mongoDB -e ME_CONFIG_MONGODB_AUTH_USERNAME=admin -e ME_CONFIG_MONGODB_AUTH_PASSWORD=admin mongo-express

My node app code looks like

const mongoose = require('mongoose');
const {Humans}= require("./models/humans.js")
mongoose.connect('mongodb://admin:admin@localhost:3535/user', {useNewUrlParser: true, useUnifiedTopology: true }).then(()=>{
    console.log("connected to db");
})

let data={
    name:"Vaibhav Jain",
    mob:"9801",
    skills:"coding"
}

const express = require('express')
const app = express();
app.set('view engine', 'ejs');


app.get("/",async(req,res)=>{
    // console.log(Humans);
    // await Humans.insertMany( );
    // await Humans.insertMany({name:"Mobius" , mob:"5908922",skills:"drawing"});
    const result = await Humans.find();
    res.send(result);   
    
})
app.get("/home",(req,res)=>{
    res.render("home", data);
})

app.listen(3000,()=>{
    console.log("listening port");
})

Also one thing i would like to mention I have created a user database which have a collection human , this all I created from UI but I wanted to connect it to my app using mongoose , so for that Human which is shown to be imported is actually empty schema (read that from somewhere that you can use existing collections in such a way please correct me on this part also if I am wrong )

Convert Hex to base64 in react js

enter image description here

I am Fetch thumbnail path from localhost 8080 and wanted to convert it into hex to base64 (Already a hex coded ) and then show the image. how this Is done in react js and display the image in the IMG tag. please help

//CODE

import React, { Component } from "react";
import ReactDOM from "react-dom";
import ColumnResizer from "column-resizer";
import "./table.css"
import axios from "axios";  
   
class ReactTable extends Component {
  constructor(props) {
    super(props);
    this.tableSelector = "#somethingUnique";
    this.state = {
      Data: [],
      Data1: [],
      error: '',
      image: [],
    }
  }    
  //Fetching Api through LocalHost8080
  getFetchData() {
    axios.get(' /AmpRestAPI/webresources/getPCRList/all',
      {
        headers: {
          'Access-Control-Allow-Origin': '*',
        },
        auth: {
          username: 'admin',
          password: 'password'
        }
      })
      .then(async (response) => {
        console.log(response.data);
        this.setState({ Data: response.data });

      }).catch(error => {
        this.setState({ error: 'unable to fetch URL' });
        console.log(error.response);
      });
  }          
  componentDidMount() {    
    if (this.props.resizable) {
      this.enableResize();
      this.getFetchData();
    }
  }   
  render() {
    const { Data, error } = this.state
    return (
      <div>

        <div className="container-fluid pt-3">
          <table id="somethingUnique" cellSpacing="0" className="border-primary">
            <thead>                  
            </thead>
            <tbody>
              {Data.length ?
                Data.map((val, index) => {
                  //flitter
                  const filterValue = this.props.filterValue;
                  const emplogin = val.ChannelName.toLowerCase();
                  // const emptype = emp.type;
                  if (((!filterValue) || (emplogin.indexOf(filterValue) !== -1))) {
                    return (
                      <tr key={index}>
                        <td>
                          {this.state.image ? <img src={`data:image/jpeg;base64,${val.Thumbnail}`} alt="Clip Thumbnail" width="100%" height="100%" /> : ''}
                        </td>
                        <td>
                            {val.ChannelName}
                         </td>
                        <td>{val.Duration}  </td>                       
                          <td>  {val.EndTime}
                          </td>
                        <td>
                            {val.LoadedClip}
                         </td>
                        <td>
                            {val.StartTime}
                         </td>

                        <td>
                            {val.CurrentTimeStamp}
                        </td>
                      </tr>
            )
                  }
            return true;
                }
            ) : null
              }
          </tbody>
        </table>
        {
          error ? <div className="text-center pt-4"><h5>{error}</h5></div> : null
        }
      </div >
      </div >
    );
  }
}    
export default ReactTable;

I am Fetch thumbnail path from localhost 8080 and wanted to convert it into hex to base64 (Already a hex coded ) and then show the image. how this Is done in react js and display the image in the IMG tag. please help

Pass a laravel variable into a jquery array

I am trying to pass a variable into a jquery autocomplete script check this url (https://jsfiddle.net/duoc5bbh/1/) I found.

Laravel

@foreach($data as $value)
   {{ $value-> email }}
   {{ $value-> name }}
@endforeach

Jquery

$(function() {
  let users = [{
      "email": "[email protected]",
      "name": "marie"
      }, 
      {
       "email": "[email protected]",
       "name": "miss"
     }];
});

what I did

$(function() {
  let users = [{
      "email": {{ $value-> email }},
      "name": {{ $value-> name }}
      }];
});

I am new in using laravel with jquery I need your help in this Thanks.

Why is Dockerized node.js Server with Vanija JS client not connecting over Socket.io

Git repo

I have an app, composed of:

  1. MySQL server
  2. scraper (node.js)
    • app parse data from website and save it to MySQL.
  3. server (node.js)
    • listening for upcoming connections over socket.io and serving data to the client.
  4. client (Vanilla JS/HTML)

server/controllers/SocketController.js

// Server: http server and socket init
const http = require('http').createServer();
const io = require('socket.io')(http, {
    cors: { origin: "*" }
});

http.listen(3001,() => console.log('Server listening on 3001'));

server/Dockerfile

FROM node:16

WORKDIR /server

COPY /server/package.json .

RUN npm install

COPY /server .

EXPOSE 3001
CMD [ "node", "index.js" ]

web/app.js

// Client listen on localhost:3001
const socket = io('ws://server:3001/');

When working locally everything worked fine, then I decided to make my life miserable and try to dockerize the whole thing (using docker the first time).
First, everything went smooth, made MySQL, scraper, and server up and working just fine.

Then it came to the point I would need to set up Nginx webserver I did so inside docker-compose.yml

docker-compose.yml

version: "3.7"

services:
  mysqldb:
    image: mysql:5.7
    container_name: mysql
    restart: unless-stopped
    env_file:
      - ./.env
    environment:
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_PASSWORD: ${MYSQL_ADMIN_PASSWORD}
      MYSQL_USER: ${MYSQL_ADMIN_USERNAME}
    ports:
      - $MYSQL_PORT:$MYSQL_PORT
    volumes:
      - ./db:/docker-entrypoint-initdb.d
    networks:
        - celtra_lottery_network

  scraper:
    restart: unless-stopped
    container_name: scraper
    build:
      context: .
      dockerfile: ./scraper/Dockerfile
    image: scraper
    env_file:
      - ./.env
    ports:
      - $NODE_SCRAPER_PORT:$NODE_SCRAPER_PORT
    volumes:
      - ./scraper:/scraper
      - /scraper/node_modules
    depends_on:
      - mysqldb
    stdin_open: true
    tty: true
    networks:
        - celtra_lottery_network

  server:
    restart: unless-stopped
    container_name: server
    build:
      context: .
      dockerfile: ./server/Dockerfile
    image: server
    env_file:
      - ./.env
    ports:
      - $NODE_SERVER_PORT:$NODE_SERVER_PORT
    volumes:
      - ./server:/server
      - /server/node_modules
    depends_on:
      - mysqldb
    stdin_open: true
    tty: true
    networks:
        - celtra_lottery_network

  client:
    image: nginx
    container_name: client
    ports:
        - 80:80
    volumes:
      - ./web:/usr/share/nginx/html
    networks:
      - celtra_lottery_network
    links:
      - server

volumes:
  db-config: null
  db-data:

networks:
   celtra_lottery_network:
      driver: bridge

When I open Nginx container in the browser, it shows the page but the data is not there. Strangely the console is not showing any error msg.

Already try it:

  • Is the server inside docker running ✔️
  • Is the server port exposed ✔️
  • Change the client connection string to ‘0.0.0.0:3001’ ✔️

I assumed that I would connect to socket the same way I was connecting server and scraper to MySQL so:

  • Host would be the docker-container-name
  • Port would be the EXPOSE 3001 port that the server is listening on.

Question:
Can someone point out the problem in my code would be really grateful for any help.