Skip to content

Commit

Permalink
Merge pull request #5 from chrishutchinson/feature/addSchemeToHostname
Browse files Browse the repository at this point in the history
Make the URL scheme part of the hostname
  • Loading branch information
Chris Hutchinson authored Dec 16, 2018
2 parents da0f7cc + 2296580 commit 4ef836b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/bundle.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions packages/client/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ColorResult, Mode } from "../types";

export const getTree = (hostname: string) =>
fetch(`http://${hostname}/api/v1/tree`).then(res => {
fetch(`${hostname}/api/v1/tree`).then(res => {
if (res.status !== 200) throw new Error(res.statusText);
return res.json();
});

export const getPixels = (hostname: string) =>
fetch(`http://${hostname}/api/v1/pixels`).then(res => {
fetch(`${hostname}/api/v1/pixels`).then(res => {
if (res.status !== 200) throw new Error(res.statusText);
return res.json();
});
Expand All @@ -17,7 +17,7 @@ export const setPixelColor = (
pixelId: number,
{ rgb }: ColorResult
) =>
fetch(`http://${hostname}/api/v1/pixel/${pixelId}`, {
fetch(`${hostname}/api/v1/pixel/${pixelId}`, {
method: "post",
body: JSON.stringify({
color: rgb
Expand All @@ -31,21 +31,21 @@ export const setPixelColor = (
});

export const setMode = (hostname: string, mode: Mode) =>
fetch(`http://${hostname}/api/v1/mode/${mode.toLowerCase()}`, {
fetch(`${hostname}/api/v1/mode/${mode.toLowerCase()}`, {
method: "post"
}).then(res => {
if (res.status !== 200) throw new Error(res.statusText);
return res;
});

export const getBrightness = (hostname: string) =>
fetch(`http://${hostname}/api/v1/pixels/brightness`).then(res => {
fetch(`${hostname}/api/v1/pixels/brightness`).then(res => {
if (res.status !== 200) throw new Error(res.statusText);
return res.json();
});

export const setBrightness = (hostname: string, brightness: number) =>
fetch(`http://${hostname}/api/v1/pixels/brightness`, {
fetch(`${hostname}/api/v1/pixels/brightness`, {
method: "post",
body: JSON.stringify({
brightness
Expand Down

0 comments on commit 4ef836b

Please sign in to comment.