REST API响应状态sode

时间:2017-04-23 07:13:54

标签: rest

我正在拿todos,如果数据库有todos我返回200状态代码,但如果数据库没有todo那么我应该返回哪个状态代码?

if(!todos->isEmpty()){
    return response()->json(['todos' => $todos], 200);
}
else{
    return response()->json(['todos' => 'No Todos'], 404);
    // OR
    //return response()->json(['todos' => NULL], 404);
    // OR
    //return response()->json(['todos' => NULL], 200);
    // OR
    //return response()->json(['todos' => array()], 404);
    // OR
    //return response()->json(['todos' => array()], 200);
}

0 个答案:

没有答案