@@ -32,19 +32,19 @@ curl -X GET -G "http://localhost/api/users" \
3232```
3333
3434``` javascript
35- var settings = {
36- " async" : true ,
37- " crossDomain" : true ,
38- " url" : " http://localhost/api/users" ,
39- " method" : " GET" ,
40- " headers" : {
41- " Accept" : " application/json" ,
42- }
35+ const url = new URL (" http://localhost/api/users" );
36+
37+ let headers = {
38+ " Accept" : " application/json" ,
39+ " Content-Type" : " application/json" ,
4340}
4441
45- $ .ajax (settings).done (function (response ) {
46- console .log (response);
47- });
42+ fetch (url, {
43+ method: " GET" ,
44+ headers: headers,
45+ })
46+ .then (response => response .json ())
47+ .then (json => console .log (json));
4848```
4949
5050> Example response:
@@ -72,19 +72,19 @@ curl -X GET -G "http://localhost/api/users/create" \
7272```
7373
7474``` javascript
75- var settings = {
76- " async" : true ,
77- " crossDomain" : true ,
78- " url" : " http://localhost/api/users/create" ,
79- " method" : " GET" ,
80- " headers" : {
81- " Accept" : " application/json" ,
82- }
75+ const url = new URL (" http://localhost/api/users/create" );
76+
77+ let headers = {
78+ " Accept" : " application/json" ,
79+ " Content-Type" : " application/json" ,
8380}
8481
85- $ .ajax (settings).done (function (response ) {
86- console .log (response);
87- });
82+ fetch (url, {
83+ method: " GET" ,
84+ headers: headers,
85+ })
86+ .then (response => response .json ())
87+ .then (json => console .log (json));
8888```
8989
9090> Example response:
@@ -112,19 +112,19 @@ curl -X POST "http://localhost/api/users" \
112112```
113113
114114``` javascript
115- var settings = {
116- " async" : true ,
117- " crossDomain" : true ,
118- " url" : " http://localhost/api/users" ,
119- " method" : " POST" ,
120- " headers" : {
121- " Accept" : " application/json" ,
122- }
115+ const url = new URL (" http://localhost/api/users" );
116+
117+ let headers = {
118+ " Accept" : " application/json" ,
119+ " Content-Type" : " application/json" ,
123120}
124121
125- $ .ajax (settings).done (function (response ) {
126- console .log (response);
127- });
122+ fetch (url, {
123+ method: " POST" ,
124+ headers: headers,
125+ })
126+ .then (response => response .json ())
127+ .then (json => console .log (json));
128128```
129129
130130
@@ -145,19 +145,19 @@ curl -X GET -G "http://localhost/api/users/{user}" \
145145```
146146
147147``` javascript
148- var settings = {
149- " async" : true ,
150- " crossDomain" : true ,
151- " url" : " http://localhost/api/users/{user}" ,
152- " method" : " GET" ,
153- " headers" : {
154- " Accept" : " application/json" ,
155- }
148+ const url = new URL (" http://localhost/api/users/{user}" );
149+
150+ let headers = {
151+ " Accept" : " application/json" ,
152+ " Content-Type" : " application/json" ,
156153}
157154
158- $ .ajax (settings).done (function (response ) {
159- console .log (response);
160- });
155+ fetch (url, {
156+ method: " GET" ,
157+ headers: headers,
158+ })
159+ .then (response => response .json ())
160+ .then (json => console .log (json));
161161```
162162
163163> Example response:
@@ -185,19 +185,19 @@ curl -X GET -G "http://localhost/api/users/{user}/edit" \
185185```
186186
187187``` javascript
188- var settings = {
189- " async" : true ,
190- " crossDomain" : true ,
191- " url" : " http://localhost/api/users/{user}/edit" ,
192- " method" : " GET" ,
193- " headers" : {
194- " Accept" : " application/json" ,
195- }
188+ const url = new URL (" http://localhost/api/users/{user}/edit" );
189+
190+ let headers = {
191+ " Accept" : " application/json" ,
192+ " Content-Type" : " application/json" ,
196193}
197194
198- $ .ajax (settings).done (function (response ) {
199- console .log (response);
200- });
195+ fetch (url, {
196+ method: " GET" ,
197+ headers: headers,
198+ })
199+ .then (response => response .json ())
200+ .then (json => console .log (json));
201201```
202202
203203> Example response:
@@ -225,19 +225,19 @@ curl -X PUT "http://localhost/api/users/{user}" \
225225```
226226
227227``` javascript
228- var settings = {
229- " async" : true ,
230- " crossDomain" : true ,
231- " url" : " http://localhost/api/users/{user}" ,
232- " method" : " PUT" ,
233- " headers" : {
234- " Accept" : " application/json" ,
235- }
228+ const url = new URL (" http://localhost/api/users/{user}" );
229+
230+ let headers = {
231+ " Accept" : " application/json" ,
232+ " Content-Type" : " application/json" ,
236233}
237234
238- $ .ajax (settings).done (function (response ) {
239- console .log (response);
240- });
235+ fetch (url, {
236+ method: " PUT" ,
237+ headers: headers,
238+ })
239+ .then (response => response .json ())
240+ .then (json => console .log (json));
241241```
242242
243243
@@ -260,19 +260,19 @@ curl -X DELETE "http://localhost/api/users/{user}" \
260260```
261261
262262``` javascript
263- var settings = {
264- " async" : true ,
265- " crossDomain" : true ,
266- " url" : " http://localhost/api/users/{user}" ,
267- " method" : " DELETE" ,
268- " headers" : {
269- " Accept" : " application/json" ,
270- }
263+ const url = new URL (" http://localhost/api/users/{user}" );
264+
265+ let headers = {
266+ " Accept" : " application/json" ,
267+ " Content-Type" : " application/json" ,
271268}
272269
273- $ .ajax (settings).done (function (response ) {
274- console .log (response);
275- });
270+ fetch (url, {
271+ method: " DELETE" ,
272+ headers: headers,
273+ })
274+ .then (response => response .json ())
275+ .then (json => console .log (json));
276276```
277277
278278
0 commit comments