Last active
November 26, 2018 02:05
-
-
Save ginpei/9312aaf3c86ec2e28dae02530b60d72f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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