When I try to return the localDescription
from the code below, I get a response that does not contains candidate
parameter under sdp
, as shown in the screenshot.
Can anyone please help me understand what am I missing here?
Also, I am not using something like conn.onicecandidate = evt => {}
on purpose because I directly want to return a value from the function below.
async function getLocalDesc() {
const conn = new RTCPeerConnection();
conn.createDataChannel('');
const offer = await conn.createOffer();
await conn.setLocalDescription(offer);
return conn.localDescription;
}
(async () => {
console.log(await getLocalDesc())
})();