I'm trying to make a function that can loop through Instagram photos and like them one by one but I couldn't figure out the syntax error I got.
likeTagsProcess = async (tags = []) => {
for (let tag of tags) {
// Go to the hashtag page
await instagram.page.goto(TAG_URL(tag), {
waitUntil: 'networkidle2'
});
await instagram.page.waitFor(1000);
let posts = await instagram.page.$$('article > div:nth-child(3) img[decoding="auto"]');
for (let i = 0; i < 3; i++) {
let post = posts[i];
// Click on the post
await post.click();
// Wait for the modal to appear
await instagram.page.waitFor('span[id="react-root"][arria-hidden="true"]');
await instagram.page.waitFor(1000);
// Liking Posts
let isLikable = await instagram.page.$('span[aria-label="Like"]');
if (isLikable) {
// Clicking Like
await instagram.page.click('span[aria-label="Like"]');
}
await instagram.page.waitFor(2500);
// Close the modal
await instagram.page.click("body > div._2dDPU.CkGkG > div.Igw0E.IwRSH.eGOV_._4EzTm.BI4qX.qJPeX.fm1AK.TxciK.yiMZG > button > svg");
await instagram.page.waitFor(1000);
}
await instagram.page.waitFor(10000);
}
}
typescript throws this error:
Syntax Error : likeTagsProcess = async (tags = []) => {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid shorthand property initializer
Please login or Register to submit your answer