I am trying to keep my response url and the response body for further processing. if I return res.json() like I normally do, then I lose the res.url value.
But if I add code to get the res.url, then I'm having trouble getting my res.json() promise to resolve.
My last attempt was to try to make an async/await function for the res.json() but that isn't working for me either:
fetch(url, options).then((res)=>{
let obj = getJSON(res);
let profileUrn = res.url.match(/(?<=urn%3Ali%3Afsd_profile%3A).+(?=&)/)[0];
let rep = {
profileUrn,
obj
};
return rep;
}
).then((data)=>{
console.log(data.profileUrn);
console.log(data.obj);
}
);
async function getJSON(res){
let data = await res.json();
return data;
};