Laravel/Vue.js - Timer












1















I would like to ask for help.
I downloaded this project to learn how to use Vue.js:
https://justlaravel.com/vue-js-crud-laravel/



I wanted to do an automatic data download every 1sec from the database. I got to the point that I can make a button to update this method but I can not do it on time.



The button on which it works:



 <button class="btn btn-primary" @click.prevent="getVueItems()" id="name" name="name">
<span class="glyphicon glyphicon-plus"></span> Refresh
</button>


Automatic refresh that does not work:



<script type="text/javascript">
getVueItems();
</script>


The Vue.js method:



  methods: {
getVueItems: function getVueItems() {
var _this = this;

axios.get('/vueitems').then(function (response) {
_this.items = response.data;
});
setTimeout(getVueItems(), 1000);
},









share|improve this question

























  • please provide code snippets instead of screenshots

    – Boussadjra Brahim
    Nov 14 '18 at 20:09











  • Use setInterval setInterval(function(){ alert("Hello world"); }, 3000); here you can find more infomation renatello.com/code/vue-js-polling-using-setinterval

    – live2
    Nov 14 '18 at 20:46













  • @live2 i have suggested a solution using that function

    – Boussadjra Brahim
    Nov 14 '18 at 20:52
















1















I would like to ask for help.
I downloaded this project to learn how to use Vue.js:
https://justlaravel.com/vue-js-crud-laravel/



I wanted to do an automatic data download every 1sec from the database. I got to the point that I can make a button to update this method but I can not do it on time.



The button on which it works:



 <button class="btn btn-primary" @click.prevent="getVueItems()" id="name" name="name">
<span class="glyphicon glyphicon-plus"></span> Refresh
</button>


Automatic refresh that does not work:



<script type="text/javascript">
getVueItems();
</script>


The Vue.js method:



  methods: {
getVueItems: function getVueItems() {
var _this = this;

axios.get('/vueitems').then(function (response) {
_this.items = response.data;
});
setTimeout(getVueItems(), 1000);
},









share|improve this question

























  • please provide code snippets instead of screenshots

    – Boussadjra Brahim
    Nov 14 '18 at 20:09











  • Use setInterval setInterval(function(){ alert("Hello world"); }, 3000); here you can find more infomation renatello.com/code/vue-js-polling-using-setinterval

    – live2
    Nov 14 '18 at 20:46













  • @live2 i have suggested a solution using that function

    – Boussadjra Brahim
    Nov 14 '18 at 20:52














1












1








1








I would like to ask for help.
I downloaded this project to learn how to use Vue.js:
https://justlaravel.com/vue-js-crud-laravel/



I wanted to do an automatic data download every 1sec from the database. I got to the point that I can make a button to update this method but I can not do it on time.



The button on which it works:



 <button class="btn btn-primary" @click.prevent="getVueItems()" id="name" name="name">
<span class="glyphicon glyphicon-plus"></span> Refresh
</button>


Automatic refresh that does not work:



<script type="text/javascript">
getVueItems();
</script>


The Vue.js method:



  methods: {
getVueItems: function getVueItems() {
var _this = this;

axios.get('/vueitems').then(function (response) {
_this.items = response.data;
});
setTimeout(getVueItems(), 1000);
},









share|improve this question
















I would like to ask for help.
I downloaded this project to learn how to use Vue.js:
https://justlaravel.com/vue-js-crud-laravel/



I wanted to do an automatic data download every 1sec from the database. I got to the point that I can make a button to update this method but I can not do it on time.



The button on which it works:



 <button class="btn btn-primary" @click.prevent="getVueItems()" id="name" name="name">
<span class="glyphicon glyphicon-plus"></span> Refresh
</button>


Automatic refresh that does not work:



<script type="text/javascript">
getVueItems();
</script>


The Vue.js method:



  methods: {
getVueItems: function getVueItems() {
var _this = this;

axios.get('/vueitems').then(function (response) {
_this.items = response.data;
});
setTimeout(getVueItems(), 1000);
},






javascript laravel vue.js timer vuejs2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 20:21









Boussadjra Brahim

8,0343632




8,0343632










asked Nov 14 '18 at 20:04









LaryLary

83




83













  • please provide code snippets instead of screenshots

    – Boussadjra Brahim
    Nov 14 '18 at 20:09











  • Use setInterval setInterval(function(){ alert("Hello world"); }, 3000); here you can find more infomation renatello.com/code/vue-js-polling-using-setinterval

    – live2
    Nov 14 '18 at 20:46













  • @live2 i have suggested a solution using that function

    – Boussadjra Brahim
    Nov 14 '18 at 20:52



















  • please provide code snippets instead of screenshots

    – Boussadjra Brahim
    Nov 14 '18 at 20:09











  • Use setInterval setInterval(function(){ alert("Hello world"); }, 3000); here you can find more infomation renatello.com/code/vue-js-polling-using-setinterval

    – live2
    Nov 14 '18 at 20:46













  • @live2 i have suggested a solution using that function

    – Boussadjra Brahim
    Nov 14 '18 at 20:52

















please provide code snippets instead of screenshots

– Boussadjra Brahim
Nov 14 '18 at 20:09





please provide code snippets instead of screenshots

– Boussadjra Brahim
Nov 14 '18 at 20:09













Use setInterval setInterval(function(){ alert("Hello world"); }, 3000); here you can find more infomation renatello.com/code/vue-js-polling-using-setinterval

– live2
Nov 14 '18 at 20:46







Use setInterval setInterval(function(){ alert("Hello world"); }, 3000); here you can find more infomation renatello.com/code/vue-js-polling-using-setinterval

– live2
Nov 14 '18 at 20:46















@live2 i have suggested a solution using that function

– Boussadjra Brahim
Nov 14 '18 at 20:52





@live2 i have suggested a solution using that function

– Boussadjra Brahim
Nov 14 '18 at 20:52












1 Answer
1






active

oldest

votes


















0














I could provide you a solution which simulates your use case, by defining a method to fetch data from database (in my case an online API which provide the current date and time) and call that method in created hook, and by taking advantage of setInterval function we could get data every second.



Run this code snippet that i hope it could help you :






new Vue({
el: '#app',
data() {
return {
now: 0
};
},
created: function() {

this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

setInterval(() => {
this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

}, 1000);
},

methods: {

fetchTemp(uri) {

axios.get(uri).then((res) => {
this.now = new Date(res.data.fulldate).toLocaleString();


}).catch(err => {});
}
}
})

<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
<meta charset="utf-8">
<title></title>
<script src="https://unpkg.com/vue@2.5.17/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/vue-axios@2.1.4/dist/vue-axios.min.js"></script>
</head>

<body>
<div id="app">
<h1> Now : {{now}} </h1>
</div>
</body>

</html>








share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307968%2flaravel-vue-js-timer%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I could provide you a solution which simulates your use case, by defining a method to fetch data from database (in my case an online API which provide the current date and time) and call that method in created hook, and by taking advantage of setInterval function we could get data every second.



    Run this code snippet that i hope it could help you :






    new Vue({
    el: '#app',
    data() {
    return {
    now: 0
    };
    },
    created: function() {

    this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

    setInterval(() => {
    this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

    }, 1000);
    },

    methods: {

    fetchTemp(uri) {

    axios.get(uri).then((res) => {
    this.now = new Date(res.data.fulldate).toLocaleString();


    }).catch(err => {});
    }
    }
    })

    <!DOCTYPE html>
    <html lang="en" dir="ltr">

    <head>
    <meta charset="utf-8">
    <title></title>
    <script src="https://unpkg.com/vue@2.5.17/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://unpkg.com/vue-axios@2.1.4/dist/vue-axios.min.js"></script>
    </head>

    <body>
    <div id="app">
    <h1> Now : {{now}} </h1>
    </div>
    </body>

    </html>








    share|improve this answer




























      0














      I could provide you a solution which simulates your use case, by defining a method to fetch data from database (in my case an online API which provide the current date and time) and call that method in created hook, and by taking advantage of setInterval function we could get data every second.



      Run this code snippet that i hope it could help you :






      new Vue({
      el: '#app',
      data() {
      return {
      now: 0
      };
      },
      created: function() {

      this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

      setInterval(() => {
      this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

      }, 1000);
      },

      methods: {

      fetchTemp(uri) {

      axios.get(uri).then((res) => {
      this.now = new Date(res.data.fulldate).toLocaleString();


      }).catch(err => {});
      }
      }
      })

      <!DOCTYPE html>
      <html lang="en" dir="ltr">

      <head>
      <meta charset="utf-8">
      <title></title>
      <script src="https://unpkg.com/vue@2.5.17/dist/vue.js"></script>
      <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
      <script src="https://unpkg.com/vue-axios@2.1.4/dist/vue-axios.min.js"></script>
      </head>

      <body>
      <div id="app">
      <h1> Now : {{now}} </h1>
      </div>
      </body>

      </html>








      share|improve this answer


























        0












        0








        0







        I could provide you a solution which simulates your use case, by defining a method to fetch data from database (in my case an online API which provide the current date and time) and call that method in created hook, and by taking advantage of setInterval function we could get data every second.



        Run this code snippet that i hope it could help you :






        new Vue({
        el: '#app',
        data() {
        return {
        now: 0
        };
        },
        created: function() {

        this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

        setInterval(() => {
        this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

        }, 1000);
        },

        methods: {

        fetchTemp(uri) {

        axios.get(uri).then((res) => {
        this.now = new Date(res.data.fulldate).toLocaleString();


        }).catch(err => {});
        }
        }
        })

        <!DOCTYPE html>
        <html lang="en" dir="ltr">

        <head>
        <meta charset="utf-8">
        <title></title>
        <script src="https://unpkg.com/vue@2.5.17/dist/vue.js"></script>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <script src="https://unpkg.com/vue-axios@2.1.4/dist/vue-axios.min.js"></script>
        </head>

        <body>
        <div id="app">
        <h1> Now : {{now}} </h1>
        </div>
        </body>

        </html>








        share|improve this answer













        I could provide you a solution which simulates your use case, by defining a method to fetch data from database (in my case an online API which provide the current date and time) and call that method in created hook, and by taking advantage of setInterval function we could get data every second.



        Run this code snippet that i hope it could help you :






        new Vue({
        el: '#app',
        data() {
        return {
        now: 0
        };
        },
        created: function() {

        this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

        setInterval(() => {
        this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

        }, 1000);
        },

        methods: {

        fetchTemp(uri) {

        axios.get(uri).then((res) => {
        this.now = new Date(res.data.fulldate).toLocaleString();


        }).catch(err => {});
        }
        }
        })

        <!DOCTYPE html>
        <html lang="en" dir="ltr">

        <head>
        <meta charset="utf-8">
        <title></title>
        <script src="https://unpkg.com/vue@2.5.17/dist/vue.js"></script>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <script src="https://unpkg.com/vue-axios@2.1.4/dist/vue-axios.min.js"></script>
        </head>

        <body>
        <div id="app">
        <h1> Now : {{now}} </h1>
        </div>
        </body>

        </html>








        new Vue({
        el: '#app',
        data() {
        return {
        now: 0
        };
        },
        created: function() {

        this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

        setInterval(() => {
        this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

        }, 1000);
        },

        methods: {

        fetchTemp(uri) {

        axios.get(uri).then((res) => {
        this.now = new Date(res.data.fulldate).toLocaleString();


        }).catch(err => {});
        }
        }
        })

        <!DOCTYPE html>
        <html lang="en" dir="ltr">

        <head>
        <meta charset="utf-8">
        <title></title>
        <script src="https://unpkg.com/vue@2.5.17/dist/vue.js"></script>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <script src="https://unpkg.com/vue-axios@2.1.4/dist/vue-axios.min.js"></script>
        </head>

        <body>
        <div id="app">
        <h1> Now : {{now}} </h1>
        </div>
        </body>

        </html>





        new Vue({
        el: '#app',
        data() {
        return {
        now: 0
        };
        },
        created: function() {

        this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

        setInterval(() => {
        this.fetchTemp('https://script.googleusercontent.com/a/macros/esi.dz/echo?user_content_key=ypoXRw1nVHj-h1VRDmh6TXSI1VpIPWW7Qo2n9El6RqoxAJ3v28nBI9bDY_4UAE0TQJ3pSozxpbTiRvFpmD8pvcTkGSnPAtgRm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_nRPgeZU6HP_B2BW4qWwVPUuHIcJ3mEdrfLIfNZsYUQi0c--vxV_3BX606CngcowlqSfFH8SSiqMPrUuXDMsd72r-P39_jlVDMh0BMLnMwXU02UuEHWiuob4ULL2SJgrtyBAf43AAwP8&lib=MwxUjRcLr2qLlnVOLh12wSNkqcO1Ikdrk');

        }, 1000);
        },

        methods: {

        fetchTemp(uri) {

        axios.get(uri).then((res) => {
        this.now = new Date(res.data.fulldate).toLocaleString();


        }).catch(err => {});
        }
        }
        })

        <!DOCTYPE html>
        <html lang="en" dir="ltr">

        <head>
        <meta charset="utf-8">
        <title></title>
        <script src="https://unpkg.com/vue@2.5.17/dist/vue.js"></script>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <script src="https://unpkg.com/vue-axios@2.1.4/dist/vue-axios.min.js"></script>
        </head>

        <body>
        <div id="app">
        <h1> Now : {{now}} </h1>
        </div>
        </body>

        </html>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 20:17









        Boussadjra BrahimBoussadjra Brahim

        8,0343632




        8,0343632
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307968%2flaravel-vue-js-timer%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python