From fd266435c99bc4922c8a12c745cd6099bdcc8f18 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Fri, 11 Aug 2017 21:07:57 -0400 Subject: [PATCH] Use real API for whitelist add/remove --- src/utils.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils.js b/src/utils.js index e93798c..3cd32d2 100644 --- a/src/utils.js +++ b/src/utils.js @@ -84,16 +84,21 @@ export const api = { getWhitelist() { return this.get("dns/whitelist"); }, - //TODO: Implement whitelisting in FTL API addWhitelist(domain) { - return new Promise(resolve => setTimeout(() => resolve({ status: "success" }), 1000)); + return this.post("dns/whitelist", { "domain": domain }); }, removeWhitelist(domain) { - return new Promise(resolve => setTimeout(() => resolve({ status: "success" }), 1000)); + return this.delete("dns/whitelist/" + domain); }, get(url) { return fetch(this.urlFor(url)).then(data => data.json()); }, + post(url, data) { + return fetch(this.urlFor(url), { method: "POST", body: JSON.stringify(data) }).then(data => data.json()); + }, + delete(url) { + return fetch(this.urlFor(url), { method: "DELETE" }).then(data => data.json()); + }, urlFor(endpoint) { let apiLocation;