UNPKG

react-native-surveys

Version:

Build your own forms, surveys and polls for your React Native apps.

43 lines (42 loc) 1.12 kB
import { config } from "../config"; import { protectWithKey } from "../utils"; const key = "r0yPEUfm0BLQED02MQOGXqG1DW"; export const getSenderLocation = () => { return new Promise(resolve => { let hasLocation = false; setTimeout(() => { if (!hasLocation) resolve(""); }, 5000); fetch(config.LOCATION_API_URL) .then(async result => { const json = await result.json(); resolve(json); }) .catch(() => resolve("")); }); }; export const hasOpenedForm = async ({ l, id, f }) => { const res = await fetch(config.SERVER_URL + "/form-inbox/opened", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ license: protectWithKey(l, key), formName: f, formId: id }) }); return await res.json(); }; export const sendCompletedForm = form => fetch(config.SERVER_URL + "/form-inbox/completed", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ license: protectWithKey(form.license, key), formData: form }) });