If I want to fetch the refresh token value (i.e abcdefghijklmp) from the below JSON Object, how can I do that? Example:
let headers = {
Cookie: [
'_fbp=70924796;
_ga=GA1.390;
_gcl_au=1.78.1649398389;
_gid=148122.1649398390;
refresh_token=abcdefghijklmp'
]
}
You could split the string:
let str = "_fbp=70924796; _ga=GA1.390; _gcl_au=1.78.1649398389; _gid=148122.1649398390; refresh_token=abcdefghijklmp"
let tokenArr = str.split("; ")
.map(s => s.split("="))
.find(split => split[0] === "refresh_token")
if (tokenArr && tokenArr.length > 1) {
let token = tokenArr[1]
console.log(token)
} else {
console.log("Token not found")
}