Skip to content

Instantly share code, notes, and snippets.

@mattupham
Last active August 29, 2023 02:19
Show Gist options
  • Save mattupham/83d018d5bb371303aa4b8294eb2a93d4 to your computer and use it in GitHub Desktop.
Save mattupham/83d018d5bb371303aa4b8294eb2a93d4 to your computer and use it in GitHub Desktop.
likes
async function postData(url = "", data = {}) {
// Default options are marked with *
const response = await fetch(url, {
method: "POST", // *GET, POST, PUT, DELETE, etc.
mode: "cors", // no-cors, *cors, same-origin
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
credentials: "same-origin", // include, *same-origin, omit
headers: {
"Content-Type": "application/json",
// 'Content-Type': 'application/x-www-form-urlencoded',
},
redirect: "follow", // manual, *follow, error
referrerPolicy: "no-referrer", // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
body: JSON.stringify(data), // body data type must match "Content-Type" header
});
return response.json(); // parses JSON response into native JavaScript objects
}
const delay = (message) => {
return new Promise((resolve) =>
setTimeout(function () {
console.log(message);
resolve();
}, 50)
);
};
const data = {
audienceId: "bb4acb7816dc47e39fea7af8c6e1485e",
audienceName: "",
presentationId: 2605026,
reactionType: "like",
slideId: 57833845,
};
const increaseLikes = async () => {
const res = await postData(
"https://audience.ahaslides.com/api/reaction/",
data
).then((data) => console.log(data));
return res;
};
(async () => {
while (true) {
increaseLikes();
await delay("Yes");
}
})();
@Shuzuehuxh7e2i
Copy link

Nice code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment