File tree Expand file tree Collapse file tree 10 files changed +56
-84
lines changed
Expand file tree Collapse file tree 10 files changed +56
-84
lines changed Original file line number Diff line number Diff line change @@ -55,10 +55,11 @@ export class AppComponent {
5555 emailValidationCallback = async ( params ) => {
5656 const emailValidationUrl = 'https://js.devexpress.com/Demos/NetCore/RemoteValidation/CheckUniqueEmailAddress' ;
5757
58- const result = await lastValueFrom ( this . httpClient . post ( emailValidationUrl , {
59- id : params . data . id ,
60- email : params . value ,
61- } , {
58+ const result = await lastValueFrom ( this . httpClient . get ( emailValidationUrl , {
59+ params : {
60+ id : params . data . id ,
61+ email : params . value ,
62+ } ,
6263 responseType : 'json' ,
6364 } ) ) ;
6465
Original file line number Diff line number Diff line change @@ -21,16 +21,10 @@ function calculateFullName({ firstName, lastName }: Employee) {
2121const emailValidationUrl = 'https://js.devexpress.com/Demos/NetCore/RemoteValidation/CheckUniqueEmailAddress' ;
2222
2323async function emailValidationCallback ( options : ValidationCallbackData ) : Promise < boolean > {
24- const response = await fetch ( emailValidationUrl , {
25- method : 'POST' ,
26- headers : {
27- 'Content-Type' : 'application/json;' ,
28- } ,
29- body : JSON . stringify ( {
30- id : options . data . id ,
31- email : options . value ,
32- } ) ,
33- } ) ;
24+ const response = await fetch ( `${ emailValidationUrl } ?${ new URLSearchParams ( {
25+ id : options . data . id ,
26+ email : options . value ,
27+ } ) } `) ;
3428
3529 return response . json ( ) ;
3630}
Original file line number Diff line number Diff line change @@ -25,16 +25,12 @@ function calculateFullName({ firstName, lastName }) {
2525const emailValidationUrl =
2626 'https://js.devexpress.com/Demos/NetCore/RemoteValidation/CheckUniqueEmailAddress' ;
2727async function emailValidationCallback ( options ) {
28- const response = await fetch ( emailValidationUrl , {
29- method : 'POST' ,
30- headers : {
31- 'Content-Type' : 'application/json;' ,
32- } ,
33- body : JSON . stringify ( {
28+ const response = await fetch (
29+ `${ emailValidationUrl } ?${ new URLSearchParams ( {
3430 id : options . data . id ,
3531 email : options . value ,
36- } ) ,
37- } ) ;
32+ } ) } ` ,
33+ ) ;
3834 return response . json ( ) ;
3935}
4036function hireDateValidationCallback ( options ) {
Original file line number Diff line number Diff line change @@ -194,16 +194,10 @@ const emailValidationUrl = 'https://js.devexpress.com/Demos/NetCore/RemoteValida
194194async function emailValidationCallback(
195195 params : ValidationCallbackData ,
196196): Promise <boolean > {
197- const response = await fetch (emailValidationUrl , {
198- method: ' POST' ,
199- headers: {
200- ' Content-Type' : ' application/json;' ,
201- },
202- body: JSON .stringify ({
203- id: params .data .id ,
204- email: params .value ,
205- }),
206- });
197+ const response = await fetch (` ${emailValidationUrl }?${new URLSearchParams ({
198+ id: params .data .id ,
199+ email: params .value ,
200+ })} ` );
207201
208202 const result = await response .json ();
209203
Original file line number Diff line number Diff line change @@ -114,13 +114,12 @@ $(() => {
114114 validationCallback ( params ) {
115115 return $ . ajax ( {
116116 url : 'https://js.devexpress.com/Demos/NetCore/RemoteValidation/CheckUniqueEmailAddress' ,
117- type : 'POST ' ,
117+ type : 'GET ' ,
118118 dataType : 'json' ,
119- contentType : 'application/json' ,
120- data : JSON . stringify ( {
119+ data : {
121120 id : params . data . id ,
122121 email : params . value ,
123- } ) ,
122+ } ,
124123 } ) ;
125124 } ,
126125 } ] ,
Original file line number Diff line number Diff line change @@ -28,8 +28,10 @@ export class AppComponent {
2828
2929 pattern = / ^ \( \d { 3 } \) \d { 3 } - \d { 4 } $ / i;
3030
31+ baseUrl = 'https://js.devexpress.com/Demos/NetCore' ;
32+
3133 constructor ( private httpClient : HttpClient ) {
32- const url = 'https://js.devexpress.com/Demos/NetCore/ api/DataGridEmployeesValidation' ;
34+ const url = ` ${ this . baseUrl } / api/DataGridEmployeesValidation` ;
3335
3436 this . dataSource = AspNetData . createStore ( {
3537 key : 'ID' ,
@@ -44,12 +46,13 @@ export class AppComponent {
4446 }
4547
4648 asyncValidation = async ( params : Record < string , unknown > & { data : Record < string , unknown > } ) => {
47- const emailValidationUrl = 'https://js.devexpress.com/Demos/NetCore/ RemoteValidation/CheckUniqueEmailAddress' ;
49+ const emailValidationUrl = ` ${ this . baseUrl } / RemoteValidation/CheckUniqueEmailAddress` ;
4850
49- const result = await lastValueFrom ( this . httpClient . post ( emailValidationUrl , {
50- id : params . data . ID ,
51- email : params . value ,
52- } , {
51+ const result = await lastValueFrom ( this . httpClient . get ( emailValidationUrl , {
52+ params : {
53+ id : params . data . ID ,
54+ email : params . value ,
55+ } ,
5356 responseType : 'json' ,
5457 } ) ) ;
5558
Original file line number Diff line number Diff line change @@ -6,8 +6,9 @@ import DataGrid, {
66import type { IAsyncRuleProps } from 'devextreme-react/data-grid' ;
77import { createStore } from 'devextreme-aspnet-data-nojquery' ;
88
9- const url = 'https://js.devexpress.com/Demos/NetCore/api/DataGridEmployeesValidation' ;
10- const emailValidationUrl = 'https://js.devexpress.com/Demos/NetCore/RemoteValidation/CheckUniqueEmailAddress' ;
9+ const baseUrl = 'https://js.devexpress.com/Demos/NetCore' ;
10+ const url = `${ baseUrl } /api/DataGridEmployeesValidation` ;
11+ const emailValidationUrl = `${ baseUrl } /RemoteValidation/CheckUniqueEmailAddress` ;
1112
1213const dataSource = createStore ( {
1314 key : 'ID' ,
@@ -21,17 +22,10 @@ const dataSource = createStore({
2122} ) ;
2223
2324const asyncValidation : IAsyncRuleProps [ 'validationCallback' ] = async ( params ) => {
24- const response = await fetch ( emailValidationUrl , {
25- method : 'POST' ,
26- headers : {
27- 'Content-Type' : 'application/json;' ,
28- } ,
29- body : JSON . stringify ( {
30- id : params . data . ID ,
31- email : params . value ,
32- } ) ,
33- } ) ;
34-
25+ const response = await fetch ( `${ emailValidationUrl } ?${ new URLSearchParams ( {
26+ id : params . data . ID ,
27+ email : params . value ,
28+ } ) } `) ;
3529 const result = await response . json ( ) ;
3630
3731 return result ;
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ import DataGrid, {
1010} from 'devextreme-react/data-grid' ;
1111import { createStore } from 'devextreme-aspnet-data-nojquery' ;
1212
13- const url = 'https://js.devexpress.com/Demos/NetCore/api/DataGridEmployeesValidation ' ;
14- const emailValidationUrl =
15- 'https://js.devexpress.com/Demos/NetCore/ RemoteValidation/CheckUniqueEmailAddress' ;
13+ const baseUrl = 'https://js.devexpress.com/Demos/NetCore' ;
14+ const url = ` ${ baseUrl } /api/DataGridEmployeesValidation` ;
15+ const emailValidationUrl = ` ${ baseUrl } / RemoteValidation/CheckUniqueEmailAddress` ;
1616const dataSource = createStore ( {
1717 key : 'ID' ,
1818 loadUrl : url ,
@@ -24,16 +24,12 @@ const dataSource = createStore({
2424 } ,
2525} ) ;
2626const asyncValidation = async ( params ) => {
27- const response = await fetch ( emailValidationUrl , {
28- method : 'POST' ,
29- headers : {
30- 'Content-Type' : 'application/json;' ,
31- } ,
32- body : JSON . stringify ( {
27+ const response = await fetch (
28+ `${ emailValidationUrl } ?${ new URLSearchParams ( {
3329 id : params . data . ID ,
3430 email : params . value ,
35- } ) ,
36- } ) ;
31+ } ) } ` ,
32+ ) ;
3733 const result = await response . json ( ) ;
3834 return result ;
3935} ;
Original file line number Diff line number Diff line change @@ -48,8 +48,9 @@ import {
4848import { type ValidationCallbackData } from ' devextreme-vue/common' ;
4949import { createStore } from ' devextreme-aspnet-data-nojquery' ;
5050
51- const url = ' https://js.devexpress.com/Demos/NetCore/api/DataGridEmployeesValidation' ;
52- const emailValidationUrl = ' https://js.devexpress.com/Demos/NetCore/RemoteValidation/CheckUniqueEmailAddress' ;
51+ const baseUrl = ' https://js.devexpress.com/Demos/NetCore' ;
52+ const url = ` ${baseUrl }/api/DataGridEmployeesValidation ` ;
53+ const emailValidationUrl = ` ${baseUrl }/RemoteValidation/CheckUniqueEmailAddress ` ;
5354
5455const dataSource = createStore ({
5556 key: ' ID' ,
@@ -65,16 +66,10 @@ const dataSource = createStore({
6566const pattern = / ^ \( \d {3} \) \d {3} -\d {4} $ / i ;
6667
6768const asyncValidation = async (params : ValidationCallbackData ) => {
68- const response = await fetch (emailValidationUrl , {
69- method: ' POST' ,
70- headers: {
71- ' Content-Type' : ' application/json;' ,
72- },
73- body: JSON .stringify ({
74- id: params .data .ID ,
75- email: params .value ,
76- }),
77- });
69+ const response = await fetch (` ${emailValidationUrl }?${new URLSearchParams ({
70+ id: params .data .ID ,
71+ email: params .value ,
72+ })} ` );
7873
7974 const result = await response .json ();
8075
Original file line number Diff line number Diff line change 11$ ( ( ) => {
2- const url = 'https://js.devexpress.com/Demos/NetCore/api/DataGridEmployeesValidation' ;
2+ const baseUrl = 'https://js.devexpress.com/Demos/NetCore' ;
3+ const url = `${ baseUrl } /api/DataGridEmployeesValidation` ;
34
45 $ ( '#gridContainer' ) . dxDataGrid ( {
56 dataSource : DevExpress . data . AspNet . createStore ( {
@@ -50,14 +51,13 @@ $(() => {
5051 message : 'Email address is not unique' ,
5152 validationCallback ( params ) {
5253 return $ . ajax ( {
53- url : 'https://js.devexpress.com/Demos/NetCore/ RemoteValidation/CheckUniqueEmailAddress' ,
54- type : 'POST ' ,
54+ url : ` ${ baseUrl } / RemoteValidation/CheckUniqueEmailAddress` ,
55+ type : 'GET ' ,
5556 dataType : 'json' ,
56- contentType : 'application/json' ,
57- data : JSON . stringify ( {
57+ data : {
5858 id : params . data . ID ,
5959 email : params . value ,
60- } ) ,
60+ } ,
6161 } ) ;
6262 } ,
6363 } ] ,
You can’t perform that action at this time.
0 commit comments