From 3d9ea20d6d94597a5ad043684994e81370b609ce Mon Sep 17 00:00:00 2001 From: Ansis Date: Tue, 14 Jan 2025 13:05:26 +0100 Subject: [PATCH] Fix a NullReferenceException when no headers --- .../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 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 {