Reading battery voltage with esp32 using Javascript

  1. My goal is: [I Want to Read Battery Voltage In ESP32 Using Javascript]
  2. My actions are: [I Tried Using GPIO.read(pin) And ADC.read(pin) To pin 34 in ESP32 ,The Pin 34 is connected to Battery and It has to read the battery voltage from that pin. ]
  3. The result I see is: [I Am Either Getting 1 or 0 iAs output by reading that pin .When I Am Reading the same pin using arduino code i am getting proper voltage reading ]
  4. My expectation & question is: [I Need A Help And Understanding on how can i use Javascript to read that ESP32 Pin And Monitor the Battery Volatge]

Neither a microcontroller nor an OS or a framework, at least today, can guess what you want to do unless you tell them properly. Some environments make assumptions and simplifications to make user life easier, what in my opinion is (at least) confusing (if not misleading).
If you want a pin to be connected to the ADC, you have to configure the microcontroller for that. At the firmware level that means to call the proper function in the API, with the proper parameter.
If you want to read a measurement from the ADC, you have to read the ADC, not the GPIO. If the ADC has several pins enabled, it will have a mux to select which pin to convert, and you will have to indicate that somehow. At the firmware level that means to call the proper function in the API, with the proper parameter.
The ADC API lives here
I don’t have the time to check for mistakes on my part, I guess what you need is:

ADC.enable(34);
batt = ADC.read(34);