dongqichang7988 2018-10-23 19:48
浏览 45

Laravel API在响应前加上npm

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

ScreenShot

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!
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码