Skip to content

Client fails to fetch data from API  #44

@MisterJEFFREY

Description

@MisterJEFFREY

Greetings.

I wanted to try out this starter project and according to the readme file:

  • Create a repository from the GitHub template and then clone it locally to your machine.
  • In the ApiIsolated folder, copy local.settings.example.json to local.settings.json
  • Continue using either Visual Studio or Visual Studio Code.

While there is no local.settings.json in this project, the fix for this is add in a new file with the same name.

However, running the project and then navigating to the classic weather forecast page, I get the following error:

System.Text.Json.JsonException: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0. blazor.webassembly.js:1 ---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0. blazor.webassembly.js:1 at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes)
blazor.webassembly.js:1 at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
blazor.webassembly.js:1 at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
blazor.webassembly.js:1 at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
blazor.webassembly.js:1 at System.Text.Json.Utf8JsonReader.Read()
blazor.webassembly.js:1 at System.Text.Json.Serialization.JsonConverter1[[BlazorApp.Shared.WeatherForecast[], Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) blazor.webassembly.js:1 --- End of inner exception stack trace --- blazor.webassembly.js:1 at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex) blazor.webassembly.js:1 at System.Text.Json.Serialization.JsonConverter1[[BlazorApp.Shared.WeatherForecast[], Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
blazor.webassembly.js:1 at System.Text.Json.JsonSerializer.ReadCore[WeatherForecast[]](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo, ReadStack& state)
blazor.webassembly.js:1 at System.Text.Json.JsonSerializer.ContinueDeserialize[WeatherForecast[]](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonTypeInfo jsonTypeInfo)
blazor.webassembly.js:1 at System.Text.Json.JsonSerializer.d__761[[BlazorApp.Shared.WeatherForecast[], Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() blazor.webassembly.js:1 at System.Net.Http.Json.HttpContentJsonExtensions.<ReadFromJsonAsyncCore>d__51[[BlazorApp.Shared.WeatherForecast[], Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
blazor.webassembly.js:1 at System.Net.Http.Json.HttpClientJsonExtensions.d__291[[BlazorApp.Shared.WeatherForecast[], Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() blazor.webassembly.js:1 at BlazorApp.Client.Pages.FetchData.OnInitializedAsync() in \Client\Pages\FetchData.razor:line 46

Other than adding the "local.settings.json" file and making sure the api project file did include it, nothing else was changed from the starter project.

Please advise and thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions