Migrate httpDelete, httpPut
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: httpDelete
|
title: httpDelete
|
||||||
tags: browser,intermediate
|
tags: utility,url,browser,intermediate
|
||||||
---
|
---
|
||||||
|
|
||||||
Makes a `DELETE` request to the passed URL.
|
Makes a `DELETE` request to the passed URL.
|
||||||
@ -21,7 +21,9 @@ const httpDelete = (url, callback, err = console.error) => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
httpDelete('https://website.com/users/123', request => {
|
httpDelete('https://jsonplaceholder.typicode.com/posts/1', request => {
|
||||||
console.log(request.responseText);
|
console.log(request.responseText);
|
||||||
}); // 'Deletes a user from the database'
|
}); /*
|
||||||
```
|
Logs: {}
|
||||||
|
*/
|
||||||
|
```
|
||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: httpPut
|
title: httpPut
|
||||||
tags: browser,intermediate
|
tags: utility,url,browser,intermediate
|
||||||
---
|
---
|
||||||
|
|
||||||
Makes a `PUT` request to the passed URL.
|
Makes a `PUT` request to the passed URL.
|
||||||
@ -24,8 +24,20 @@ const httpPut = (url, data, callback, err = console.error) => {
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const password = "fooBaz";
|
const password = "fooBaz";
|
||||||
const data = JSON.stringify(password);
|
const data = JSON.stringify({
|
||||||
httpPut('https://website.com/users/123', data, request => {
|
id: 1,
|
||||||
|
title: 'foo',
|
||||||
|
body: 'bar',
|
||||||
|
userId: 1
|
||||||
|
});
|
||||||
|
httpPut('https://jsonplaceholder.typicode.com/posts/1', data, request => {
|
||||||
console.log(request.responseText);
|
console.log(request.responseText);
|
||||||
}); // 'Updates a user's password in database'
|
}); /*
|
||||||
```
|
Logs: {
|
||||||
|
id: 1,
|
||||||
|
title: 'foo',
|
||||||
|
body: 'bar',
|
||||||
|
userId: 1
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user