I have a project in Laravel 5.7.9
with an API. When I try to go to any of my routes I get an error saying
SyntaxError: JSON.parse: unexpected keyword at line 1 column 1 of the JSON data
This was previously working fine so did some testing and noticed the following:
In my routes/api.php
file I created the following code
Route::get('test', function(){
return 'my-test';
});
now when I head to mysite.sandbox/api/test
I get a response saying npmtest
similarly, when i try to query the API for a JSON response I get my JSON response wrapped with npm{}
npm{"data":[{"id":324,"titulo":"...","descripcion":"...",...},{"id":323,...},{"id":320,...}],"meta":{"pagination":{"total":3,"count":3,"per_page":15,"current_page":1,"total_pages":1,"links":[]}}}
I'm not sure when this broke but I do remember doing an npm install
before the error began.
What could be causing this? And how can I fix this? Would appreciate any suggestions, thanks.
Update
Here is another situation where npm
is showing up where it's not suppose to...
$ php artisan cache:clear
npmApplication cache cleared!