Created
August 30, 2018 17:46
-
-
Save sslotsky/4a549da13888d11773e9f50b3b1020b7 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
function apiUrl(endpoint) { | |
const url = new URL(`https://platform.tillmobile.com/api/${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