What can be done to resolve the error message "This language feature is only supported for ECMASCRIPT6 mode" in Google Tag Manager?

I attempted to implement some JavaScript code in GTM, but encountered an error. The error occurs at this line

window.sbHooks.addAction('sbCoreState::CreateBets/success', (data, response) => {

where I utilized a custom Vue.js hook. How can I resolve this issue?

<script>
if (typeof window.sbHooks === 'object') {
  // Send data about achieving the goal (placing bets/predictions) to Yandex Metrika
  window.sbHooks.addAction('sbCoreState::CreateBets/success', (data, response) => {
    //data.express_bet - amount of express bet, if this value exists - it's an express bet
    //data.express_tip - express text
    //added express with prediction or without
    if (
      typeof data.express_bet !== 'undefined' &&
      typeof response.body.ids !== 'undefined' &&
      Array.isArray(response.body.ids) &&
      response.body.ids.length > 0
    ) {
      if (typeof yaCounter47035968 != 'undefined') {
        yaCounter47035968.reachGoal('AddTipExpress');
        if (data.express_tip.length > 0) {
          yaCounter47035968.reachGoal('AddReviews');
        }
      }
    }

    // If there are multiple bets, iterate through them and check for text
    if (
      typeof data.express_bet == 'undefined' &&
      data.bets.length > 0
    ) {
      for (var i = 0; i <= data.bets.length - 1; i++) {
        var tip_text = data.bets[i].tip_text;
        if (typeof yaCounter47035968 != 'undefined') {
          yaCounter47035968.reachGoal('AddTipOrdinary');
          if (typeof tip_text !== 'undefined') {
            yaCounter47035968.reachGoal('AddReviews');
          }
        }
      }
    }
  });
}
</script>

Answer №1

Change the arrow function to a regular function.

  window.sbHooks.addAction('sbCoreState::CreateBets/success', function(data, response) {
// keep everything else unchanged

Answer №2

To properly modify your function, you need to remove the arrow and update it as follows:

window.sbHooks.addAction('sbCoreState::CreateBets/success', function (data, response) {

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to retrieve the value of elements that are deeply nested within multiple objects and arrays?

When making an API call to retrieve data from the Google Distance Matrix API, I store that information in my Redux store within a React application. The returned data object is structured as follows: Object { "destination_addresses": Array [ "21 Fo ...

Introduce a timeout in the ajax request

I'm currently facing an issue with adding a 2-second delay between the loader icon and the success message displaying the data as html. I attempted to use setTimeout in my ajax code with a specified delay number, but it doesn't seem to be workin ...

Vue's inability to compare an object property with a string leads to failure

Conclusion: It was a typo. I am facing an issue in Vue where I cannot seem to compare two values properly. I have an id and an object, but when I loop through the object properties to check if the ids match, it always returns false even though they appear ...

Can Java provide functionality similar to JS callbacks?

Can a similar functionality be achieved in Java? function sum(num1, num2, onComplete) { var result = num1 + num2; onComplete(result); } (function(){ sum(3, 5, function(res){alert(res)}); })() Is it possible to implement this in Java without ...

Issue with Magento site: Clicking on thumbnail photo does not update the large photo on mobile devices

As I navigate through a Magento site, I encounter a problem with the thumbnail images not reloading the larger image when clicked. Instead, the browser jumps to the top of the page and a hash symbol gets added to the URL. Based on this behavior, I suspect ...

What is the proper way to invoke render functions using Vue 3 composition API?

During my time with Vue 2, I would typically call render() in this manner: export default { mounted(){ ... }, render(){ ... }, methods(){ ... } } Now that I'm exploring Vue 3 and the composition API, I ...

Triggering AWS Lambda functions with SQS

Utilizing AWS and SES for sending emails and SMS through a Lambda function using NodeJs. I need to make more than 1k or 500 REST API calls, with the average call taking 3 seconds to execute a single lambda function request. It is essential to process mul ...

Tips for accessing .js variables in .ejs files

I am facing an issue with my index.js and list.ejs files in Express. Here is the relevant code: index.js: const express = require("express"); const app = express(); app.set("view engine", "ejs"); app.set("views", __dirname + "\\views"); let ...

Using Backbone to Handle Different Data Formats

I have a unique text file containing date-time data in the format below: 2014-03-14T16:32 2014-03-15T13:04 2014-03-16T06:44 ... I want to use this static file as a read-only data source for my backbone collection. However, the current format is not suita ...

Unable to access Bootstrap dropdown menu after initial ajax form submission

I am encountering an issue with a dropdown menu on my webpage, specifically within the manager.php file. Please excuse any formatting discrepancies as I am using Bootstrap: <!-- Bootstrap --> <script type="text/javascript" src="https://netdna ...

Tips for disabling viewport resizer while accessing the Console panel in Chrome using Control+Shift+J

Currently, I am utilizing the viewport resizer in Chrome to preview how my code appears on various devices. However, I have encountered an issue - whenever I try to access the console using ctrl + shift + j, the viewport resizer opens instead. You can obs ...

What is the reason that the slick slider is unable to remove the class filter?

Having troubles with my slickUnfilter function, even though slickFilter is working perfectly? Here's a snippet of my HTML: <div class="slider-wrapper" id="wrapper"> <div class="post" id="post1"&g ...

How can I display a spinner/loader gif when the page loads using Vue?

When it comes to loading components on a webpage, jquery has the options of $( document ).ready() and onload. But in Vue, how can we achieve the same effect? For example, when a user clicks our page, how can we display a spinner until all contents are load ...

Instructions for creating a circular image using the Next.js image component in Next.js version 13

Currently, I'm attempting to replicate an image similar to https://i.sstatic.net/EF5Nd.jpg using the latest version of next.js (version 13) with the next.js image component. However, I am encountering a slight issue where the image appears to be takin ...

React Native ScrollView ref issue resolved successfully

I'm trying to automatically scroll to the bottom of a flatlist, so here's what I have: const scrollViewRef = useRef(); //my scroll view <ScrollView ref={scrollViewRef} onContentSizeChange={() => { scrollViewRef.current.scr ...

Determine if a certain value is present in a JSON data structure

Exploring the depths of NodeJS, I am utilizing a JSON Object for user validation. JSON content (users.json): { "users": [{ "fname": "Robert", "lname": "Downey Jr.", "password": "ironman" }, { "fname": "Chris", ...

Identifying specific text enclosed within tags in an external file using PHP

I recently started learning about php, and I am looking for a script that can identify text between specific tags in an external file. I came across a solution here that extracts the text within tags from a given string. However, I am unsure how to mo ...

After using res.redirect(`/relative/url`), I encountered a PATCH 404 Not Found response. Any suggestions on resolving this issue?

Issue: I have encountered a problem while trying to update a document saved on MongoDB. I used the following code snippet for updating the document: Blog.findByIdAndUpdate(req.body.id, { 'status': req.body.status }). The updating part works perfe ...

Implementing JSON web tokens on the client side using Node.jsHere are the steps to implement

I have been developing a Node.js express application with JWT for authentication to secure access to my admin page. While testing my routes using Postman, everything works smoothly on the server side. However, I am facing a challenge on the client side in ...

Changing buffer from base64 to UTF-8 encoding in Node.js

My application imports messages from the Notes folder of Gmail using the imap npm module. When following the example on their GitHub page, all message contents are read into a buffer: stream.on('data', function(chunk) { count += chunk.len ...