0

UPDATE 1

@lukepolo found out that the number 23842515550750742 randomly always goes to 23842515550750744 in JS. Any ideas why?


I am using Laravel for an API I am creating. I am using Forge to run the servers.

When I pull a URL for the interface in Chrome, Safari, FireFox, etc., it is returning an ID that has been increased by 2. When I pull that SAME url, with the same exact request in Postman, CRUD, Terminal via cURL, etc., it returns the CORRECT response.

Results from Postman:

accountid: 1334372826597482
campaign:"Facebook"
campaignid: 23842515550750742 <-- CORRECT
client_id: 72
id: 817

Results from Chrome:

accountid:1334372826597482
campaign:"Facebook"
campaignid:23842515550750744 <-- INCORRECT
client_id:72
id:817

I am using the Facebook Marketing API to save the information locally, so I can run massive queries in a much faster resposne than their API would give me. Here is the code for listing the campaigns with basic information:

    $this->parseRequestData($request);
    $campaigns = FacebookPerformanceOverview::whereIn('client_id', $this->sheet_ids)
        ->whereIn('accountid', $this->accountIds['facebook'])
        ->whereIn('campaignid', $this->campaigns)
        ->whereBetween('date', [$this->start_date, $this->end_date])
        ->groupBy('campaignid')
        ->get();
    $response = [];
    foreach ($campaigns AS $campaign) {
        $data = FacebookPerformanceOverview::whereIn('client_id', $this->sheet_ids)
            ->whereIn('accountid', $this->accountIds['facebook'])
            ->where('campaignid', $campaign->campaignid)
            ->whereIn('adsetid', $this->adsets)
            ->whereBetween('date', [$this->start_date, $this->end_date]);
        $response[] = array(
            'company' => $campaign->company,
            'campaign' => FacebookCampaignSettings::where('campaignid', $campaign->campaignid)->first(),
            'impressions' => $data->sum('impressions'),
            'clicks' => $data->sum('clicks'),
            'cost' => $data->sum('cost'),
            'reach' => $data->sum('reach'),
            'frequency' => $data->avg('frequency'),
            'uniqueclicks' => $data->sum('uniqueclicks'),
            'actions' => $data->sum('actions'),
            'offsiteconversions' => $data->sum('offsiteconversions'),
            'leads' => $data->sum('actionsleadgen') + $this->calculateLeads(),
        );
    }
    return response()->json($response, 200, [], JSON_NUMERIC_CHECK);

I am unable to give the URL, due to it containing sensitive information, but I am confused as to what is going on. I have cleared cache, different browsers, different computers, etc. Web browsers always return the ID in the network tab incorrectly. Any ideas?

Community
  • 1
  • 1
Brian Logan
  • 812
  • 2
  • 6
  • 20

1 Answers1

2

Javascript not parsing large number in JSON correctly

Is the answer.

Community
  • 1
  • 1
LukePOLO
  • 1,110
  • 3
  • 13
  • 28