【发布时间】:2019-09-08 02:05:18
【问题描述】:
这很好用: screenshot insomnia
但是当我尝试通过 api 路由(POST http://127.0.0.1:8000/api/login 也使用 Insomnia)做同样的事情时,正确地导致了这个登录功能,我没有得到响应。我设置了超时来结束请求,否则它会在获取请求中保持“循环”。为什么这不起作用?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use GuzzleHttp\Client;
class AuthController extends Controller
{
public function login(Request $request)
{
$client = new Client([
'timeout' => 8.0,
]);
$response = $client->get('http://127.0.0.1:8000/api/all');
return response()->json($response);
}
}
【问题讨论】:
-
你试过
/api/all吗? -
只是 /api/all 导致 url 格式不正确的错误:cURL error 3:
malformed (see curl.haxx.se/libcurl/c/libcurl-errors.html) -
有人吗?我没有解决这个问题......