How to get one int value from string in request response and skip the other ones

Viewed 16

I have a problem with reading 1 value from browser console.

it looks like that

screenshot

I want to get the "xp" value and I did it, but only in that one case.

const quests = result.data.quests;
console.log(quests[1]);
var exp = quests[1].rewards;
var xp = exp.replaceAll('{"coins":3,"xp":', "");
var xp = xp.replaceAll(',"honor":0,"premium":0,"statPoints":0,"item":0}', "");
var xp = parseInt(xp);
console.log(xp);

In other cases the values of course will be different and it won't work, so how can I make the program get te same result every time?

0 Answers
Related