|
@@ -32,19 +32,19 @@ curl -X GET -G "http://localhost/api/users" \
|
|
|
```
|
|
|
|
|
|
```javascript
|
|
|
-var settings = {
|
|
|
- "async": true,
|
|
|
- "crossDomain": true,
|
|
|
- "url": "http://localhost/api/users",
|
|
|
- "method": "GET",
|
|
|
- "headers": {
|
|
|
- "Accept": "application/json",
|
|
|
- }
|
|
|
+const url = new URL("http://localhost/api/users");
|
|
|
+
|
|
|
+let headers = {
|
|
|
+ "Accept": "application/json",
|
|
|
+ "Content-Type": "application/json",
|
|
|
}
|
|
|
|
|
|
-$.ajax(settings).done(function (response) {
|
|
|
- console.log(response);
|
|
|
-});
|
|
|
+fetch(url, {
|
|
|
+ method: "GET",
|
|
|
+ headers: headers,
|
|
|
+})
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(json => console.log(json));
|
|
|
```
|
|
|
|
|
|
> Example response:
|
|
@@ -72,19 +72,19 @@ curl -X GET -G "http://localhost/api/users/create" \
|
|
|
```
|
|
|
|
|
|
```javascript
|
|
|
-var settings = {
|
|
|
- "async": true,
|
|
|
- "crossDomain": true,
|
|
|
- "url": "http://localhost/api/users/create",
|
|
|
- "method": "GET",
|
|
|
- "headers": {
|
|
|
- "Accept": "application/json",
|
|
|
- }
|
|
|
+const url = new URL("http://localhost/api/users/create");
|
|
|
+
|
|
|
+let headers = {
|
|
|
+ "Accept": "application/json",
|
|
|
+ "Content-Type": "application/json",
|
|
|
}
|
|
|
|
|
|
-$.ajax(settings).done(function (response) {
|
|
|
- console.log(response);
|
|
|
-});
|
|
|
+fetch(url, {
|
|
|
+ method: "GET",
|
|
|
+ headers: headers,
|
|
|
+})
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(json => console.log(json));
|
|
|
```
|
|
|
|
|
|
> Example response:
|
|
@@ -112,19 +112,19 @@ curl -X POST "http://localhost/api/users" \
|
|
|
```
|
|
|
|
|
|
```javascript
|
|
|
-var settings = {
|
|
|
- "async": true,
|
|
|
- "crossDomain": true,
|
|
|
- "url": "http://localhost/api/users",
|
|
|
- "method": "POST",
|
|
|
- "headers": {
|
|
|
- "Accept": "application/json",
|
|
|
- }
|
|
|
+const url = new URL("http://localhost/api/users");
|
|
|
+
|
|
|
+let headers = {
|
|
|
+ "Accept": "application/json",
|
|
|
+ "Content-Type": "application/json",
|
|
|
}
|
|
|
|
|
|
-$.ajax(settings).done(function (response) {
|
|
|
- console.log(response);
|
|
|
-});
|
|
|
+fetch(url, {
|
|
|
+ method: "POST",
|
|
|
+ headers: headers,
|
|
|
+})
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(json => console.log(json));
|
|
|
```
|
|
|
|
|
|
|
|
@@ -145,19 +145,19 @@ curl -X GET -G "http://localhost/api/users/{user}" \
|
|
|
```
|
|
|
|
|
|
```javascript
|
|
|
-var settings = {
|
|
|
- "async": true,
|
|
|
- "crossDomain": true,
|
|
|
- "url": "http://localhost/api/users/{user}",
|
|
|
- "method": "GET",
|
|
|
- "headers": {
|
|
|
- "Accept": "application/json",
|
|
|
- }
|
|
|
+const url = new URL("http://localhost/api/users/{user}");
|
|
|
+
|
|
|
+let headers = {
|
|
|
+ "Accept": "application/json",
|
|
|
+ "Content-Type": "application/json",
|
|
|
}
|
|
|
|
|
|
-$.ajax(settings).done(function (response) {
|
|
|
- console.log(response);
|
|
|
-});
|
|
|
+fetch(url, {
|
|
|
+ method: "GET",
|
|
|
+ headers: headers,
|
|
|
+})
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(json => console.log(json));
|
|
|
```
|
|
|
|
|
|
> Example response:
|
|
@@ -185,19 +185,19 @@ curl -X GET -G "http://localhost/api/users/{user}/edit" \
|
|
|
```
|
|
|
|
|
|
```javascript
|
|
|
-var settings = {
|
|
|
- "async": true,
|
|
|
- "crossDomain": true,
|
|
|
- "url": "http://localhost/api/users/{user}/edit",
|
|
|
- "method": "GET",
|
|
|
- "headers": {
|
|
|
- "Accept": "application/json",
|
|
|
- }
|
|
|
+const url = new URL("http://localhost/api/users/{user}/edit");
|
|
|
+
|
|
|
+let headers = {
|
|
|
+ "Accept": "application/json",
|
|
|
+ "Content-Type": "application/json",
|
|
|
}
|
|
|
|
|
|
-$.ajax(settings).done(function (response) {
|
|
|
- console.log(response);
|
|
|
-});
|
|
|
+fetch(url, {
|
|
|
+ method: "GET",
|
|
|
+ headers: headers,
|
|
|
+})
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(json => console.log(json));
|
|
|
```
|
|
|
|
|
|
> Example response:
|
|
@@ -225,19 +225,19 @@ curl -X PUT "http://localhost/api/users/{user}" \
|
|
|
```
|
|
|
|
|
|
```javascript
|
|
|
-var settings = {
|
|
|
- "async": true,
|
|
|
- "crossDomain": true,
|
|
|
- "url": "http://localhost/api/users/{user}",
|
|
|
- "method": "PUT",
|
|
|
- "headers": {
|
|
|
- "Accept": "application/json",
|
|
|
- }
|
|
|
+const url = new URL("http://localhost/api/users/{user}");
|
|
|
+
|
|
|
+let headers = {
|
|
|
+ "Accept": "application/json",
|
|
|
+ "Content-Type": "application/json",
|
|
|
}
|
|
|
|
|
|
-$.ajax(settings).done(function (response) {
|
|
|
- console.log(response);
|
|
|
-});
|
|
|
+fetch(url, {
|
|
|
+ method: "PUT",
|
|
|
+ headers: headers,
|
|
|
+})
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(json => console.log(json));
|
|
|
```
|
|
|
|
|
|
|
|
@@ -260,19 +260,19 @@ curl -X DELETE "http://localhost/api/users/{user}" \
|
|
|
```
|
|
|
|
|
|
```javascript
|
|
|
-var settings = {
|
|
|
- "async": true,
|
|
|
- "crossDomain": true,
|
|
|
- "url": "http://localhost/api/users/{user}",
|
|
|
- "method": "DELETE",
|
|
|
- "headers": {
|
|
|
- "Accept": "application/json",
|
|
|
- }
|
|
|
+const url = new URL("http://localhost/api/users/{user}");
|
|
|
+
|
|
|
+let headers = {
|
|
|
+ "Accept": "application/json",
|
|
|
+ "Content-Type": "application/json",
|
|
|
}
|
|
|
|
|
|
-$.ajax(settings).done(function (response) {
|
|
|
- console.log(response);
|
|
|
-});
|
|
|
+fetch(url, {
|
|
|
+ method: "DELETE",
|
|
|
+ headers: headers,
|
|
|
+})
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(json => console.log(json));
|
|
|
```
|
|
|
|
|
|
|