From dd8790612b9befc0923602b9f906ad3d53e0779a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ansis=20M=C4=81li=C5=86=C5=A1?=
 <ansis.malins@decentraland.org>
Date: Mon, 20 Jan 2025 16:05:59 +0100
Subject: [PATCH] Fix a NullReferenceException when no headers (#3116)

Co-authored-by: Ashley Canning <ashley.canning@decentraland.org>
---
 .../Apis/Modules/FetchApi/SimpleFetchApiWrapper.cs          | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Explorer/Assets/Scripts/SceneRuntime/Apis/Modules/FetchApi/SimpleFetchApiWrapper.cs b/Explorer/Assets/Scripts/SceneRuntime/Apis/Modules/FetchApi/SimpleFetchApiWrapper.cs
index 63b67ce740..24874d1c21 100644
--- a/Explorer/Assets/Scripts/SceneRuntime/Apis/Modules/FetchApi/SimpleFetchApiWrapper.cs
+++ b/Explorer/Assets/Scripts/SceneRuntime/Apis/Modules/FetchApi/SimpleFetchApiWrapper.cs
@@ -35,8 +35,10 @@ async UniTask<ResponseToJs> FetchAsync(CancellationToken ct)
                 ISimpleFetchApi.Response response = await api.FetchAsync(requestMethod, url, headers, hasBody, body, redirect, timeout, webController, ct);
 
                 var headersToJs = new PropertyBag();
-                foreach (var header in response.Headers)
-                    headersToJs.Add(header.Key, header.Value);
+
+                if (response.Headers != null)
+                    foreach (var header in response.Headers)
+                        headersToJs.Add(header.Key, header.Value);
 
                 return new ResponseToJs
                 {