How to get first instance to last instance of a number in a string in javascript regex/ object error? -
i have string "{\"id\":\"35112914\"}"
obtained after json.stringify
. want number 35112914
or first instance of number ,i.e. 3
last ,i.e., 4
. there other way of approaching ?
edit: had stringify because of weird error getting. while accessing property of object, getting undefined
answer , made number inaccessible. stringify atleast shows number .
edit 2 :
my code written in node makes curl request rest api .
curl.request(optionsrun, function (error, response) { console.log(response); settimeout(function () { id = response ; console.log(id["id"]) ; },2000) ; }) ;
output:
{"id":"35113281"} undefined
you need parse response js object before can access using js object methods:
curl.request(optionsrun, function (error, response) { var id = json.parse(response); settimeout(function () { console.log(id.id) ; }, 2000); });
Comments
Post a Comment