Laravel API Request - “Unauthorized” - laravel
Good day to you all,
Today I decided to authenticate my experimental api. I installed Passport, but I get a constant response:
{
error: {
message: "Unauthorized"
}
}
I tried disable it, and just use in api.php:
Route::get('test', function (){
return 1;
});
As a testing point, but still I get the same message, so I assume it has nothing to do with the Passport package.
Kernel.php:
<?php
namespace App\Http;
use App\Http\Middleware\Authenticate;
use App\Http\Middleware\Cors;
use App\Http\Middleware\CrossDomain;
use App\Http\Middleware\EncryptCookies;
use App\Http\Middleware\ForceJsonResponse;
use App\Http\Middleware\isAdmin;
use App\Http\Middleware\isCompany;
use App\Http\Middleware\RedirectIfAuthenticated;
use App\Http\Middleware\TrimStrings;
use App\Http\Middleware\TrustProxies;
use App\Http\Middleware\VerifyCsrfToken;
use Cog\Laravel\Ban\Http\Middleware\ForbidBannedUser;
use Cog\Laravel\Ban\Http\Middleware\LogsOutBannedUser;
use Fruitcake\Cors\HandleCors;
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
use Illuminate\Auth\Middleware\Authorize;
use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
use Illuminate\Auth\Middleware\RequirePassword;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance;
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
use Illuminate\Http\Middleware\SetCacheHeaders;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Routing\Middleware\ValidateSignature;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use RenatoMarinho\LaravelPageSpeed\Middleware\ElideAttributes;
use RenatoMarinho\LaravelPageSpeed\Middleware\InlineCss;
use RenatoMarinho\LaravelPageSpeed\Middleware\InsertDNSPrefetch;
use RenatoMarinho\LaravelPageSpeed\Middleware\RemoveComments;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* #var array
*/
protected $middleware = [
TrustProxies::class,
HandleCors::class,
PreventRequestsDuringMaintenance::class,
ValidatePostSize::class,
TrimStrings::class,
ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* #var array
*/
protected $middlewareGroups = [
'web' => [
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
CrossDomain::class,
InlineCss::class,
ElideAttributes::class,
InsertDNSPrefetch::class,
RemoveComments::class,
//CollapseWhitespace::class,
//DeferJavascript::class,
],
'api' => [
//'throttle:api',
SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* #var array
*/
protected $routeMiddleware = [
'auth' => Authenticate::class,
'auth.basic' => AuthenticateWithBasicAuth::class,
'cache.headers' => SetCacheHeaders::class,
'can' => Authorize::class,
'guest' => RedirectIfAuthenticated::class,
'password.confirm' => RequirePassword::class,
'signed' => ValidateSignature::class,
'throttle' => ThrottleRequests::class,
'verified' => EnsureEmailIsVerified::class,
'forbid-banned-user' => ForbidBannedUser::class,
'logs-out-banned-user' => LogsOutBannedUser::class,
'is_admin' => isAdmin::class,
'is_company' => isCompany::class,
'json.response' => ForceJsonResponse::class,
'cors' => Cors::class,
];
}
config/auth.php:
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
'hash' => false,
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
];
routes/api.php:
<?php
use Illuminate\Support\Facades\Route;
Route::get('test', function () {
return 1;
});
Route::group(['middleware' => ['cors', 'json.response']], function () {
Route::group(['prefix' => 'auth'], function () {
Route::post('login', 'Api\AuthController#login');
Route::group(['middleware' => 'auth:api'], function () {
Route::get('logout', 'Api\AuthController#logout');
Route::get('user', 'Api\AuthController#user');
});
});
Route::group(['middleware' => 'auth:api'], function () {
// Companies
Route::group(['prefix' => 'provider/company'], function () {
Route::post('store', 'Api\Provider\CompanyController#store');
Route::get('show/{id}', 'Api\Provider\CompanyController#show');
Route::patch('update', 'Api\Provider\CompanyController#update');
Route::delete('destroy/{id}', 'Api\Provider\CompanyController#destroy');
Route::get('branches/{id}', 'Api\Provider\CompanyController#branches');
});
// Branches
Route::group(['prefix' => 'provider/branch'], function () {
Route::post('store', 'Api\Provider\BranchController#store');
Route::get('show/{id}', 'Api\Provider\BranchController#show');
Route::patch('update', 'Api\Provider\BranchController#update');
Route::delete('destroy/{id}', 'Api\Provider\BranchController#destroy');
Route::get('classifieds/{id}', 'Api\Provider\BranchController#classifieds');
});
// Classifieds
Route::group(['prefix' => 'provider/classified'], function () {
Route::post('store', 'Api\Provider\ClassifiedController#store');
Route::get('show/{identifier}', 'Api\Provider\ClassifiedController#show');
Route::patch('update', 'Api\Provider\ClassifiedController#update');
Route::delete('destroy/{identifier}', 'Api\Provider\ClassifiedController#destroy');
});
// Attributes
Route::group(['prefix' => 'provider/data'], function () {
Route::get('categories', 'Api\Provider\DataController#categories');
Route::get('attributes/{parent_id}', 'Api\Provider\DataController#attributes');
});
});
});
Error Stack:
{
message: "Too Many Attempts.",
exception: "Illuminate\Http\Exceptions\ThrottleRequestsException",
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php",
line: 200,
trace: [
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php",
line: 121,
function: "buildException",
class: "Illuminate\Routing\Middleware\ThrottleRequests",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php",
line: 63,
function: "handleRequest",
class: "Illuminate\Routing\Middleware\ThrottleRequests",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "Illuminate\Routing\Middleware\ThrottleRequests",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 103,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
line: 697,
function: "then",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
line: 672,
function: "runRouteWithinStack",
class: "Illuminate\Routing\Router",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
line: 636,
function: "runRoute",
class: "Illuminate\Routing\Router",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
line: 625,
function: "dispatchToRoute",
class: "Illuminate\Routing\Router",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
line: 166,
function: "dispatch",
class: "Illuminate\Routing\Router",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 128,
function: "Illuminate\Foundation\Http\{closure}",
class: "Illuminate\Foundation\Http\Kernel",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\app\Http\Middleware\ForceJsonResponse.php",
line: 20,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "App\Http\Middleware\ForceJsonResponse",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\renatomarinho\laravel-page-speed\src\Middleware\PageSpeed.php",
line: 28,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\renatomarinho\laravel-page-speed\src\Middleware\PageSpeed.php",
line: 28,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\renatomarinho\laravel-page-speed\src\Middleware\PageSpeed.php",
line: 28,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\renatomarinho\laravel-page-speed\src\Middleware\PageSpeed.php",
line: 28,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\renatomarinho\laravel-page-speed\src\Middleware\PageSpeed.php",
line: 28,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\renatomarinho\laravel-page-speed\src\Middleware\PageSpeed.php",
line: 28,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\fruitcake\laravel-cors\src\HandleCors.php",
line: 57,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "Fruitcake\Cors\HandleCors",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php",
line: 21,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull.php",
line: 31,
function: "handle",
class: "Illuminate\Foundation\Http\Middleware\TransformsRequest",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php",
line: 21,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TrimStrings.php",
line: 40,
function: "handle",
class: "Illuminate\Foundation\Http\Middleware\TransformsRequest",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "Illuminate\Foundation\Http\Middleware\TrimStrings",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php",
line: 27,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "Illuminate\Foundation\Http\Middleware\ValidatePostSize",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance.php",
line: 86,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\fideloper\proxy\src\TrustProxies.php",
line: 57,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 167,
function: "handle",
class: "Fideloper\Proxy\TrustProxies",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
line: 103,
function: "Illuminate\Pipeline\{closure}",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
line: 141,
function: "then",
class: "Illuminate\Pipeline\Pipeline",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
line: 110,
function: "sendRequestThroughRouter",
class: "Illuminate\Foundation\Http\Kernel",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\public\index.php",
line: 55,
function: "handle",
class: "Illuminate\Foundation\Http\Kernel",
type: "->"
},
{
file: "C:\Users\lopes\PhpstormProjects\Ocasiao-CMS\server.php",
line: 21,
function: "require_once"
}
]
}
Can any of you give me a hint or explanation on how to fix this/
If you removed Auth middleware but still getting unauthorized means there may be route cache. Try using php artisan route:clear and check.
I just realised there was another package installed conflicting with this one.
Thank you all!
Related
Laravel ajax file upload method not allowed
Using Laravel 5.4 I'm trying to submit a form with a file to upload with ajax. My jquery code: $("#uploadRoastsForm").submit(function() { var url = $(this).attr('action'); var fd = new FormData(); var files = $('#roastFile')[0].files; if(files.length > 0) fd.append('file', files[0]); fd.append('file', files[0]); fd.append('roast_date', $('#roastDate').val()); $.ajax({ url: url, type: 'POST', data: fd, contentType: false, processData: false, success: function (data) {... My form: <form action="/warehouse/upload" method="post" enctype="multipart/form-data" class="form" id="uploadRoastsForm"> {{ csrf_field() }} <div class="form-group" style="width:150px"> <label>Roasting Date</label> <div class="input-group"> <input name="roast_date" type="text" value="{{ old('roast_date') }}" class="form-control datepick" id="roastDate"> <div class="input-group-addon"> <span class="fa fa-calendar"></span> </div> </div> </div> <div class="form-group"> <label>Upload Roast Files</label> <input type="file" name="file" id="roastFile"> </div> I am getting this in firebug: XHRPOSThttp://highland.local/warehouse/upload [HTTP/1.1 419 unknown status 250ms] message "" exception file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Exceptions\\Handler.php" line 204 trace [ {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, … ] 0 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Exceptions\\Handler.php", line: 176, function: "prepareException", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Exceptions\\Handler.php" line 176 function "prepareException" class "Illuminate\\Foundation\\Exceptions\\Handler" type "->" 1 Object { file: "C:\\wamp64\\www\\highland.local\\app\\Exceptions\\Handler.php", line: 77, function: "render", … } file "C:\\wamp64\\www\\highland.local\\app\\Exceptions\\Handler.php" line 77 function "render" class "Illuminate\\Foundation\\Exceptions\\Handler" type "->" 2 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 83, function: "render", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 83 function "render" class "App\\Exceptions\\Handler" type "->" 3 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 55, function: "handleException", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 55 function "handleException" class "Illuminate\\Routing\\Pipeline" type "->" 4 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Middleware\\ShareErrorsFromSession.php", line: 49, function: "Illuminate\\Routing\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Middleware\\ShareErrorsFromSession.php" line 49 function "Illuminate\\Routing\\{closure}" class "Illuminate\\Routing\\Pipeline" type "->" 5 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", line: 163, function: "handle", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php" line 163 function "handle" class "Illuminate\\View\\Middleware\\ShareErrorsFromSession" type "->" 6 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 53, function: "Illuminate\\Pipeline\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 53 function "Illuminate\\Pipeline\\{closure}" class "Illuminate\\Pipeline\\Pipeline" type "->" 7 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php", line: 63, function: "Illuminate\\Routing\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php" line 63 function "Illuminate\\Routing\\{closure}" class "Illuminate\\Routing\\Pipeline" type "->" 8 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", line: 163, function: "handle", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php" line 163 function "handle" class "Illuminate\\Session\\Middleware\\StartSession" type "->" 9 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 53, function: "Illuminate\\Pipeline\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 53 function "Illuminate\\Pipeline\\{closure}" class "Illuminate\\Pipeline\\Pipeline" type "->" 10 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse.php", line: 37, function: "Illuminate\\Routing\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse.php" line 37 function "Illuminate\\Routing\\{closure}" class "Illuminate\\Routing\\Pipeline" type "->" 11 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", line: 163, function: "handle", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php" line 163 function "handle" class "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse" type "->" 12 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 53, function: "Illuminate\\Pipeline\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 53 function "Illuminate\\Pipeline\\{closure}" class "Illuminate\\Pipeline\\Pipeline" type "->" 13 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php", line: 66, function: "Illuminate\\Routing\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php" line 66 function "Illuminate\\Routing\\{closure}" class "Illuminate\\Routing\\Pipeline" type "->" 14 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", line: 163, function: "handle", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php" line 163 function "handle" class "Illuminate\\Cookie\\Middleware\\EncryptCookies" type "->" 15 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 53, function: "Illuminate\\Pipeline\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 53 function "Illuminate\\Pipeline\\{closure}" class "Illuminate\\Pipeline\\Pipeline" type "->" 16 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", line: 104, function: "Illuminate\\Routing\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php" line 104 function "Illuminate\\Routing\\{closure}" class "Illuminate\\Routing\\Pipeline" type "->" 17 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", line: 684, function: "then", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php" line 684 function "then" class "Illuminate\\Pipeline\\Pipeline" type "->" 18 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", line: 659, function: "runRouteWithinStack", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php" line 659 function "runRouteWithinStack" class "Illuminate\\Routing\\Router" type "->" 19 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", line: 625, function: "runRoute", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php" line 625 function "runRoute" class "Illuminate\\Routing\\Router" type "->" 20 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", line: 614, function: "dispatchToRoute", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php" line 614 function "dispatchToRoute" class "Illuminate\\Routing\\Router" type "->" 21 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php", line: 176, function: "dispatch", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php" line 176 function "dispatch" class "Illuminate\\Routing\\Router" type "->" 22 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 30, function: "Illuminate\\Foundation\\Http\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 30 function "Illuminate\\Foundation\\Http\\{closure}" class "Illuminate\\Foundation\\Http\\Kernel" type "->" 23 Object { file: "C:\\wamp64\\www\\highland.local\\app\\Http\\Middleware\\ForceSsl.php", line: 29, function: "Illuminate\\Routing\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\app\\Http\\Middleware\\ForceSsl.php" line 29 function "Illuminate\\Routing\\{closure}" class "Illuminate\\Routing\\Pipeline" type "->" 24 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", line: 163, function: "handle", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php" line 163 function "handle" class "App\\Http\\Middleware\\ForceSsl" type "->" 25 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 53, function: "Illuminate\\Pipeline\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 53 function "Illuminate\\Pipeline\\{closure}" class "Illuminate\\Pipeline\\Pipeline" type "->" 26 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php", line: 31, function: "Illuminate\\Routing\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php" line 31 function "Illuminate\\Routing\\{closure}" class "Illuminate\\Routing\\Pipeline" type "->" 27 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", line: 163, function: "handle", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php" line 163 function "handle" class "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest" type "->" 28 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 53, function: "Illuminate\\Pipeline\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 53 function "Illuminate\\Pipeline\\{closure}" class "Illuminate\\Pipeline\\Pipeline" type "->" 29 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php", line: 31, function: "Illuminate\\Routing\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php" line 31 function "Illuminate\\Routing\\{closure}" class "Illuminate\\Routing\\Pipeline" type "->" 30 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", line: 163, function: "handle", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php" line 163 function "handle" class "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest" type "->" 31 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 53, function: "Illuminate\\Pipeline\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 53 function "Illuminate\\Pipeline\\{closure}" class "Illuminate\\Pipeline\\Pipeline" type "->" 32 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php", line: 27, function: "Illuminate\\Routing\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php" line 27 function "Illuminate\\Routing\\{closure}" class "Illuminate\\Routing\\Pipeline" type "->" 33 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", line: 163, function: "handle", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php" line 163 function "handle" class "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize" type "->" 34 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", line: 53, function: "Illuminate\\Pipeline\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php" line 53 function "Illuminate\\Pipeline\\{closure}" class "Illuminate\\Pipeline\\Pipeline" type "->" 35 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", line: 104, function: "Illuminate\\Routing\\{closure}", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php" line 104 function "Illuminate\\Routing\\{closure}" class "Illuminate\\Routing\\Pipeline" type "->" 36 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php", line: 151, function: "then", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php" line 151 function "then" class "Illuminate\\Pipeline\\Pipeline" type "->" 37 Object { file: "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php", line: 116, function: "sendRequestThroughRouter", … } file "C:\\wamp64\\www\\highland.local\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php" line 116 function "sendRequestThroughRouter" class "Illuminate\\Foundation\\Http\\Kernel" type "->" 38 Object { file: "C:\\wamp64\\www\\highland.local\\public\\index.php", line: 53, function: "handle", … } file "C:\\wamp64\\www\\highland.local\\public\\index.php" line 53 function "handle" class "Illuminate\\Foundation\\Http\\Kernel" type "->" I also tried to have an input as a submit button on the form and when I click it I call the exact same ajax, but then I got the error: MethodNotAllowed. Something breaks when I use: contentType: false, processData: false. But if I don't use them I can't send the file to the controller. Can anyone help please? How do you upload file with ajax in Laravel?
At first you didn't posted what is the method in your route/web.php for your ajax request. If it is MethodNotAllowed related problem then probably your ajax request and route method is not same. If you are trying to update something then use PUT method in your route like below Route::put('/warehouse/upload', "WarehouseController#upload'); And if you are trying to insert data into database table then use POST method: Route::post('/warehouse/upload', "WarehouseController#upload'); As you are using POST method from your jQuery AJAX function, then just use post method in your route. I think it should solve your query.
cURL error 28: Operation timed out after 10000 milliseconds
I've problem with Guzzle HTTP client, when i send post request manually (using postman) to oauth/token, i get the token and refresh token correctly but when i request sent using guzzle, it freezes and do not get any response for a while, after timeout return exception bottom "message": "cURL error 28: Operation timed out after 10000 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)", "exception": "GuzzleHttp\\Exception\\ConnectException", "file": "C:\\Users\\SMART\\Desktop\\shopkit-backend\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory.php", "line": 200, "trace": [ { "file": "C:\\Users\\SMART\\Desktop\\shopkit-backend\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory.php", "line": 155, "function": "createRejection", "class": "GuzzleHttp\\Handler\\CurlFactory", "type": "::" }, { "file": "C:\\Users\\SMART\\Desktop\\shopkit-backend\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory.php", "line": 105, "function": "finishError", "class": "GuzzleHttp\\Handler\\CurlFactory", "type": "::" }, { "file": "C:\\Users\\SMART\\Desktop\\shopkit-backend\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlHandler.php", "line": 43, "function": "finish", "class": "GuzzleHttp\\Handler\\CurlFactory", "type": "::" .... this is my code $client = new \GuzzleHttp\Client([ 'timeout' => 10 ]); //GuzzleHttp\Client try { $result = $client->post(url('oauth/token'), [ 'form_params' => [ 'grant_type' => 'password', 'client_id' => $this->_client_id, 'client_secret' => $this->_client_secret, 'username' => $user->username, 'password' => $req->password, // 'scope' => $scopes ] ]); } catch (\Guzzle\Http\Exception\ConnectException $e) { $response = json_encode((string)$e->getResponse()->getBody()); } what should i do?
Check for your firewall if it's active and disable it sudo ufw disable sudo ufw disable
How to check tags uniqueness of tags using spatie/laravel-tags plugin
Using spatie/laravel-tags plugin in my Laravel 5.7 app. I make editor of tags, so that admin would be able to add tags . However, I need to make validation on tags uniqueness. Usual validation rules like 'name' => [ 'required', 'string', 'max:255', Rule::unique(with(new Tag)->getTableName())->ignore($tag_id), ], 'order_column' => 'nullable|integer', does not work here, as fields are in json format like: {"en": "Drama"} Could you, please, give a hint in which way this validation can be done? MODIFIED BLOCK # 2 In my request app/Http/Requests/TagRequest.php I wrote validation rules: <?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Http\Request; use App\Rules\TagUniqueness; class TagRequest extends FormRequest { public function authorize() { return true; } public function rules() { // $request= Request(); return [ 'name' => [ 'required', 'string', 'max:255', new TagUniqueness, ], 'order_column' => 'nullable|integer', ]; } } and created rule app/Rules/TagUniqueness.php has: <?php namespace App\Rules; use Illuminate\Contracts\Validation\Rule; class TagUniqueness implements Rule { public function __construct() { $this->d( '<pre>TagUniqueness $_REQUEST::' . print_r( $_REQUEST, true ) ); } public function passes($attribute, $value) { $this->d( '<pre>passes $attribute::' . print_r( $attribute, true ) ); $this->d( '<pre>passes $value::' . print_r( $value, true ) ); return false; } ... and I recieved this error: "message": "trim() expects parameter 1 to be string, object given", "exception": "ErrorException", "file": "/mnt/_work_sdb8/wwwroot/lar/Votes/vendor/laravel/framework/src/Illuminate/Validation/ValidationRuleParser.php", "line": 217, "trace": [ { "function": "handleError", "class": "Illuminate\\Foundation\\Bootstrap\\HandleExceptions", "type": "->" }, { "file": "/mnt/_work_sdb8/wwwroot/lar/Votes/vendor/laravel/framework/src/Illuminate/Validation/ValidationRuleParser.php", "line": 217, "function": "trim" }, { "file": "/mnt/_work_sdb8/wwwroot/lar/Votes/vendor/laravel/framework/src/Illuminate/Validation/ValidationRuleParser.php", "line": 199, "function": "parseArrayRule", "class": "Illuminate\\Validation\\ValidationRuleParser", "type": "::" }, { "file": "/mnt/_work_sdb8/wwwroot/lar/Votes/vendor/proengsoft/laravel-jsvalidation/src/Remote/Validator.php", "line": 161, "function": "parse", "class": "Illuminate\\Validation\\ValidationRuleParser", "type": "::" }, { "file": "/mnt/_work_sdb8/wwwroot/lar/Votes/vendor/proengsoft/laravel-jsvalidation/src/Remote/Validator.php", "line": 144, "function": "purgeNonRemoteRules", "class": "Proengsoft\\JsValidation\\Remote\\Validator", "type": "->" }, { "file": "/mnt/_work_sdb8/wwwroot/lar/Votes/vendor/proengsoft/laravel-jsvalidation/src/Remote/Validator.php", "line": 116, "function": "setRemoteValidation", "class": "Proengsoft\\JsValidation\\Remote\\Validator", "type": "->" }, { as $this->d( my debugging method, I see output of TagUniqueness' s constructer, but passes method IS NOT CALLED and I can not define the reason of this error. What is wrong? Thanks!
Normalizing a nested entity that shares the current schema
My goal is to normalize this object: { talks: [ { id: 1755, speakers: [ { id: 1487, name: 'John Doe', }, ], related_talks: [{ id: 14, speakers: [{ id: 125, name: 'Jane Doe', }], event: { id: 181, name: 'First Annual', }, }], event: { id: 180, name: 'July Party', }, }, ], }; into this result: { entities: { events: { 181: { id: 181, name: 'First Annual' }, 180: { id: 180, name: 'July Party' } }, speakers: { 125: { id: 125, name: 'Jane Doe' }, 1487: { id: 1487, name: 'John Doe' } }, talks: { 1755: { id: 1755, event: 181, speakers: [ 1487 ], related_talks: [ 14 ], }, 14: { id: 14, speakers: [ 125 ], event: 180, } }, }, result: { talks: [ 1755, 14 ], }, } If you'll notice, the items in related_talks are treated the same as a talk. My schemas follow the examples and are set up like this: const speaker = new schema.Entity('speakers'); const event = new schema.Entity('events'); export const talk = new schema.Entity('talks', { speakers: [speaker], event, }); talk.define({ related_talks: [talk] }); No matter what I try, I can't get the items in related_talks to be added to the result.talks array. It is, however, in the entities object. What is my schema configuration missing in order to accommodate this?
Unfortunately, if this is your requirement, Normalizr is not for you. Alternatively, if you're looking for a list of "talks" by ID, you can use Object.keys(data.entities.talks)
Why is my ExtJS 4.2 gridpanel sort not working?
Not sure why my sort is not working for this gridpanel. I set the sorters property, I believe correctly. And I set the sortOnLoad property as well. Not sure why this simple case is not working. I don't think I need to do a remote sort in this case, so just not sure why this is not working. Ext.onReady(function() { Ext.define('com.myCompany.MyGridModel', { extend : 'Ext.data.Model', fields : [{ name : 'name', type : 'string' }, { name : 'address', type : 'string' }, { name : 'type', type : 'string' }] }); var store = Ext.create('Ext.data.Store', { model: 'com.myCompany.MyGridModel', proxy: { type: 'ajax', url: 'centers.json', reader: { type: 'json', root: 'centers' }, sortOnLoad: true, sorters: { property: 'name', direction : 'ASC' } } }); store.load(); var grid = Ext.create('Ext.grid.Panel', { layout: 'fit', store: store, columns: [{ text: 'Name', dataIndex: 'name', name: 'name' }, { text: 'IP Address', dataIndex: 'address', name: 'address' }, { text: 'Type', dataIndex: 'type', name: 'type' }], renderTo: Ext.getBody(), }); grid.getView().refresh(); }); { "centers": [ { "name": "South Test Center", "address": "30.40.50.60", "type": "TestType2" }, { "name": "East Test Center", "address": "50.60.70.80", "type": "TestType1" }, { "name": "West Test Center", "address": "40.50.60.70", "type": "TestType3" }, { "name": "North Test Center", "address": "20.30.40.50", "type": "TestType4" } ] }
The sortOnLoad and sorters configuration options should be placed directly on the store, not on the model. See the Ext.data.Store documentation here: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store-cfg-sorters http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store-cfg-sortOnLoad