[Vuejs]-How we save the recorded data and replay again using rrweb?

1👍

  1. Make sure your endpoint is working fine, unless you put ‘deadend/getrrbData’ to not reveal your endpoint.
    Reference link for fetch with then callback:
    https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch

    1. Also a thing to mention, since rrweb record returns a function that stops recording, I don’t know if you were able to play the recorded events because you were calling vm.play after stopping recording events.
    2. Apart from POST url endpoint I really did not find any potential issue with your code, check this post fetch request example
      // Example POST method implementation:
      
      try {
        const data = await postData('http://example.com/answer', { answer: 42 });
        console.log(JSON.stringify(data)); // JSON-string from `response.json()` call
      } catch (error) {
        console.error(error);
      }
      
      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
          referrer: 'no-referrer', // no-referrer, *client
          body: JSON.stringify(data) // body data type must match "Content-Type" header
        });
        return await response.json(); // parses JSON response into native JavaScript objects
      }

To replay after sending post request

you can use the same events that you sent in your body of POST

Good luck!

Leave a comment