When a user selects one or more checkboxes and submits a form, data in the database is updated. At that moment, I call location.reload() from the code to reload the page and display the correct data.
Below is the backend web API code:
[HttpGet]
public async Task<object> Get()
{
var entries = await _entryRepository.GetEntriesByUserIdAsync(await GetUserId());
var result = _mapper.Map<IEnumerable<Entries>, IEnumerable<EntryReponse>>(entries);
return Ok(result);
}
Here is the service code that calls the web API:
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions } from '@angular/http';
import 'rxjs/add/operator/map';
import { AuthService } from "./auth.service";
import { Entry } from "../models/entry";
import { Observable } from 'rxjs/Rx';
@Injectable()
export class EntryService
{
private readonly API_URL = 'http://localhost:52841/api/entry/';
constructor(private http: Http,
private authService: AuthService) { }
// Methods for creating, getting, and updating entries
}
Below is the component code:
import { Component, OnInit } from '@angular/core';
import { EntryService } from "../../services/entry.service";
import { MasterCodeService } from "../../services/masterCode.service";
import { SubCodeService } from "../../services/subcode.service";
import { Entry } from "../../models/entry";
import { MasterCode } from "../../models/masterCodes";
// Defines the EntryListComponent class with properties and methods
Upon submitting, an error occurs which states "An unhandled exception occurred while processing the request. JsonReaderException: Unexpected character encountered while parsing value". The issue seems related to JSON parsing. Can you suggest a solution to fix this problem?
Update: Provided links show JSON data before and after reloading the page, along with headers on first call and after reloading. Some URL paths allow manual calling into the browser, while others only work when called from links. How can this inconsistency be resolved where all components, services, and links are created similarly? Any insights would be appreciated. Kind Regards, Danijel