Skip to content

Instantly share code, notes, and snippets.

@banagale
Created May 12, 2021 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banagale/c34e2febff5b7a6a5dd721e4d87f980f to your computer and use it in GitHub Desktop.
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
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