From 6143f7a6fe730bf7547c97b5dcf5aa01f9f3cd24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 19:53:36 +0100 Subject: [PATCH] update tag_database, update httpPost --- snippets/httpPost.md | 9 ++++----- tag_database | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/snippets/httpPost.md b/snippets/httpPost.md index 40eb5ec59..ffa11a633 100644 --- a/snippets/httpPost.md +++ b/snippets/httpPost.md @@ -4,16 +4,15 @@ Makes a `POST` request to the passed URL. Use `XMLHttpRequest` web api to make a `post` request to the given `url`. Set the value of an `HTTP` request header with `setRequestHeader` method. -Handle the `onload` event, by running the provided `callback` function. +Handle the `onload` event, by console logging the `responseText`. Handle the `onerror` event, by running the provided `err` function. -Omit the last argument, `err` to log the request to the console's error stream by default. ```js -const httpPost = (url, data, callback, err = console.error) => { +const httpPost = (url, data, err = console.error) => { const request = new XMLHttpRequest(); request.open("POST", url, true); request.setRequestHeader('Content-type','application/json; charset=utf-8'); - request.onload = () => callback(request); + request.onload = () => console.log(request.responseText); request.onerror = () => err(request); request.send(data); }; @@ -27,5 +26,5 @@ const user = { const data = JSON.stringify(user); httpPost('https://website.com/posts', data, request => { console.log(request.responseText); -}); // 'Makes a new instance of user in database' +}); // '' ``` diff --git a/tag_database b/tag_database index 6de2c2662..8e768751d 100644 --- a/tag_database +++ b/tag_database @@ -61,10 +61,8 @@ hasFlags:node head:array hexToRGB:utility,string,math,advanced hide:browser,css -httpDelete:utility,url,browser httpGet:utility,url,browser httpPost:utility,url,browser -httpPut:utility,url,browser httpsRedirect:browser,url indexOfAll:array initial:array