• Return JSON data in the request interface

    Route::get('req', function () {
        return ['id'=>'0', 'name'=>'dzm'];
    });
    
    Route::get('req', function () {
        return response()->json(['id'=>'0', 'name'=>'dzm']);
    });
    Copy the code

  • Modify the interface return status, the previous return is 200, sometimes request error, need to return the corresponding error status code.

    Route::get('req', function () {Route::get('req', function () { The default of 200 / / return the response () - > json ([' id '= >' 0 ', 'name' = > 'DZM], 201); });Copy the code