0
我有Laravel 5.4由2个项目:如何使用Laravel 5.4从API端点检索JSON?
- PRJ-1这是一个雷斯特夫尔API返回JSON。
- Prj-2它是一个消耗上述端点的网站。
就这样,我从PRJ-1后续的端点: myAPI.com/city返回在JSON格式数据库中的所有城市的列表。
内PRJ-2我有如下:
Route:
Route::get('/showCityAPItest','[email protected]');
Controller:
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
...
public function getcity()
{
$request =Request::create('http://myAPI.com/city', 'GET');
$response = Route::dispatch($request);
dd($response);
}
如果我直接在浏览器使用URL(http://myAPI.com/city),它的工作原理。我可以按预期看到JSON。 当我尝试从Prj-2中检索它时,我无法在浏览器中看到它。
其实我看到
404 Not Found
nginx/1.10.1 (Ubuntu)
我下面这个post但我不知道我在做什么错。
任何帮助?