Replace fetch with Axios in client
Replace `.then` with await syntax where possible.
GitLab: #142
Change-Id: I6c132f49f152afa7e20919a1c70c539f2ad54878
diff --git a/client/src/contexts/WebRTCProvider.tsx b/client/src/contexts/WebRTCProvider.tsx
index be5a045..86950f7 100644
--- a/client/src/contexts/WebRTCProvider.tsx
+++ b/client/src/contexts/WebRTCProvider.tsx
@@ -211,24 +211,21 @@
const sendWebRTCOffer = useCallback(async () => {
if (webRTCConnection && socket) {
- webRTCConnection
- .createOffer({
- offerToReceiveAudio: true,
- offerToReceiveVideo: true,
- })
- .then((sdp) => {
- socket.send({
- type: WebSocketMessageType.WebRTCOffer,
- data: {
- from: account.getId(),
- to: contactId,
- message: {
- sdp: sdp,
- },
- },
- });
- webRTCConnection.setLocalDescription(new RTCSessionDescription(sdp));
- });
+ const sdp = await webRTCConnection.createOffer({
+ offerToReceiveAudio: true,
+ offerToReceiveVideo: true,
+ });
+ socket.send({
+ type: WebSocketMessageType.WebRTCOffer,
+ data: {
+ from: account.getId(),
+ to: contactId,
+ message: {
+ sdp,
+ },
+ },
+ });
+ await webRTCConnection.setLocalDescription(new RTCSessionDescription(sdp));
}
}, [account, contactId, socket, webRTCConnection]);