php - 用 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 }
解决方案
推荐阅读
- python - 为什么替换只在某些场合有效?
- mysql - 具有两个引用的主键
- javascript - 正则表达式检测带有 2+ 数字和 2+ 字符的单词
- python - 基于 CSV 的登录系统问题
- protractor - E/launcher - 进程退出,错误代码为 100
- php - 我的 ajax 调用得到了正确的响应,但没有做任何事情
- python - 在 Python 中对“命令式外壳,功能核心”进行单元测试时遇到问题
- makefile - 生成文件到 CodeLite
- cakephp - Cake : 未能打开 stream() 权限
- python - 在 python 中执行代码时如何更改 URL 中的脚本名称