Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpInterceptor with DevExtreme.AspNet.Data doesn't work Angular 6 #309

Closed
pilouk opened this issue Nov 28, 2018 · 1 comment
Closed

HttpInterceptor with DevExtreme.AspNet.Data doesn't work Angular 6 #309

pilouk opened this issue Nov 28, 2018 · 1 comment
Assignees

Comments

@pilouk
Copy link

pilouk commented Nov 28, 2018

Angular 6 here
HttpInterceptor doesn't intercept the call from the DevExtreme.AspNet.Data
The token is not added to the query

Do you guys use HttpClient ?

Must use HttpClient since angular 4.3+

@pilouk pilouk changed the title HttpInterceptor in Angular 2+ doesn't work HttpInterceptor with DevExtreme.AspNet.Data doesn't work Nov 28, 2018
@pilouk pilouk changed the title HttpInterceptor with DevExtreme.AspNet.Data doesn't work HttpInterceptor with DevExtreme.AspNet.Data doesn't work Angualr 6 Nov 28, 2018
@pilouk pilouk changed the title HttpInterceptor with DevExtreme.AspNet.Data doesn't work Angualr 6 HttpInterceptor with DevExtreme.AspNet.Data doesn't work Angular 6 Nov 28, 2018
@AlekseyMartynov AlekseyMartynov self-assigned this Nov 29, 2018
@AlekseyMartynov
Copy link
Contributor

Hello @pilouk

Indeed, currently there's no way to use Angular's HTTP API for AJAX requests.
We plan to improve this (#311).

Here is how you can solve two typical tasks without the use of HttpInterceptor.

Customize a request (URL, headers, query string, HTTP verb)

import * as AspNetData from "devextreme-aspnet-data-nojquery";

const store = AspNetData.createStore({
  // . . .

  onBeforeSend: (operation, ajaxOptions) => {
    ajaxOptions.headers = {
      "Authorization": "..."
    };
  }
});

The members of ajaxOptions are available in the TypeScript declaration.

Redirect to a login form upon receiving Unauthorized response

store["_errorHandler"] = (e: Error) => {
  if (e.message.indexOf("Unauthorized") > -1)
    location.href = "/login";
};

Related: #297, #310

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants