Reading and storing value from the pin of the bolt into variable

i am calling this function onload().i want to read the data from the pin 5 and store it in a this code i am storing in it variable p. how to store the data of pin-5 in a variable
function new_func(5l){

var value = 5
var p = “/digitalRead?pin=”+value;

Instead of putting the function in body tag use this

var pinXValue =0document.body.onload =function () {
   // get data here
  pinXValue = fetchedValue;

my doubt is to get data from the pin

Ah, you need to make a http request, use this