首页 > 解决方案 > 用 200 返回响应消息

问题描述

我试图弄清楚如何转储从我正在点击的端点返回的实际状态消息,但我不太明白如何获取它。

目前,我正在访问端点并使用 try/catch 块。在尝试部分,我点击它,刷新会话并创建一条 200 消息。当我现在点击这个时,我会在下面收到我的成功消息:

$authService = new AuthService();
$authLogout = $authService->logout($logoutToken);

Session::flush();

$response = json_decode(response()->json(['success' => 'success'], 200);
dd($response);

所以我知道它是成功的,但我想返回端点实际以 200 状态发回的 JSON 解码消息。

我怎样才能正确地做到这一点?

更新:响应()上的 Var 转储

object(Illuminate\Http\JsonResponse)#762 (9) { ["data":protected]=> string(21) "{"success":"success"}" ["callback":protected]=> NULL ["encodingOptions":protected]=> int(0) ["headers"]=> object(Symfony\Component\HttpFoundation\ResponseHeaderBag)#760 (5) { ["computedCacheControl":protected]=> array(1) { ["no-cache"]=> bool(true) } ["cookies":protected]=> array(0) { } ["headerNames":protected]=> array(2) { ["cache-control"]=> string(13) "Cache-Control" ["content-type"]=> string(12) "Content-Type" } ["headers":protected]=> array(2) { ["cache-control"]=> array(1) { [0]=> string(8) "no-cache" } ["content-type"]=> array(1) { [0]=> string(16) "application/json" } } ["cacheControl":protected]=> array(0) { } } ["content":protected]=> string(21) "{"success":"success"}" ["version":protected]=> string(3) "1.0" ["statusCode":protected]=> int(200) ["statusText":protected]=> string(2) "OK" ["charset":protected]=> NULL }

标签: phplaravel

解决方案


推荐阅读