Documentation / @ember-data/adapter / error / UnauthorizedError
Defined in: packages/adapter/src/error.js:255
A UnauthorizedError
equates to a HTTP 401 Unauthorized
response status. It is used by an adapter to signal that a request to the external API was rejected because authorization is required and has failed or has not yet been provided.
An example use case would be to redirect the user to a login route if a request is unauthorized:
app/routes/application.js
js
import { UnauthorizedError } from '@ember-data/adapter/error';
export default class ApplicationRoute extends Route {
@action
error(error, transition) {
if (error instanceof UnauthorizedError) {
// go to the login route
this.transitionTo('login');
return;
}
// ...other error handling logic
}
}
UnauthorizedError
Properties
code
ts
code: string;
Defined in: packages/adapter/src/error.js:259