Created
May 12, 2021 15:03
-
-
Save banagale/c34e2febff5b7a6a5dd721e4d87f980f to your computer and use it in GitHub Desktop.
A React Query function that POSTs user behavioral events to /events/ from the frontend
This file contains hidden or 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
import Cookies from "js-cookie"; | |
import { wvApiUrl } from "../../routes"; | |
const fetchUrl = wvApiUrl.events(); | |
export async function useSendGatheringEvent(bodyData) { | |
const response = await fetch(fetchUrl, { | |
method: 'POST', | |
body: JSON.stringify(bodyData), | |
headers: { | |
"Content-type": "application/json", | |
"X-CSRFToken": Cookies.get('csrftoken') | |
} | |
}); | |
return await response.json(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment