Skip to content

Instantly share code, notes, and snippets.

@ginpei
Last active November 26, 2018 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ginpei/9312aaf3c86ec2e28dae02530b60d72f to your computer and use it in GitHub Desktop.
Save ginpei/9312aaf3c86ec2e28dae02530b60d72f to your computer and use it in GitHub Desktop.
// https://api.developer.lifx.com/docs/breathe-effect
(async () => {
const token = prompt('Token?');
const selector = 'all';
const url = `https://api.lifx.com/v1/lights/${selector}/effects/breathe`;
const params = {
color: 'red',
cycles: 3,
}
try {
const res = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
},
body: new URLSearchParams(params)
});
console.log(res.status, res.statusText);
if (res.ok) {
const body = await res.json();
console.log(body);
}
else {
console.error('Failed');
}
}
catch (error) {
console.error(error);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment