JSFiddle - React, Tailwind, and code Playground

by Wolf

HTML

<html>

  <head>
    <script src="https://www.google.com/maps/api/js/reviews?key=AIzaSyCOW7b0eVJzLBlTz1eY9XP04VJ48C_uaMQ">

    </script>
  </head>

  <body>
    <button onclick="createReview()">Review this place</button>
  </body>

</html>

JavaScript

function verify() {
  console.log(google.places.reviews);
  console.log(google.places.reviews.createPublishReviewFlow);
}

function createReview() {
  // Set the review options: a place ID, an initial rating, and
  // some default review text.
  var publishReviewOptions = {};
  publishReviewOptions.placeId = 'ChIJcUZbqhy6j4ARBQXggSvXCWQ';
  publishReviewOptions.initialRating = 3;
  publishReviewOptions.initialReviewText = 'Default review text';

// Instantiate and begin the publishing flow.
  var googlePublishReviewFlow = google.places.reviews.createPublishReviewFlow(publishReviewOptions);

  // Wire up the events.
  googlePublishReviewFlow.addListener('publish', function()   {
    console.log('Published!');
  });
  googlePublishReviewFlow.addListener('complete', function() {
    console.log('Complete!');
  });
  googlePublishReviewFlow.addListener('cancel', function()   {
    console.log('Canceled!');
  });
  googlePublishReviewFlow.addListener('error', function() {
    console.log('Error');
  });
}