Skip to content

Instantly share code, notes, and snippets.

@sslotsky sslotsky/api.js
Created Aug 30, 2018

What would you like to do?
function apiUrl(endpoint) {
const url = new URL(`${endpoint}`);
url.searchParams.set("username", process.env.REACT_APP_TILL_USERNAME);
url.searchParams.set("api_key", process.env.REACT_APP_TILL_API_KEY);
return url;
function postData(url, data) {
return fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json; charset=utf-8"
body: JSON.stringify(data)
export async function sendMessage(phoneNumbers, message) {
const res = await postData(apiUrl("send"), {
phone: phoneNumbers,
text: message
return res.json();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.