Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mariante's avatar

Working with PHP in VUE

Hi, I'm trying to work with PHP in VUE... But I'm getting stuck in here...

this.$http.get('../api/api.php', {params: {pagination: this.pagination}})
            .then(response => {
              this.$set('items', response.data)
              this.$set('pagination', response.data.pagination)
              console.log(items)
            })
            .catch(e => {
              // this.errors.push(e)
              console.log(e)
            })

Only returns: 404 (Not Found) Already changed to .src/api/api.php, src/api/api.php ... for everything that you can imagine and nothing, only 404. If I use XAMPP to host api.php and use http://localhost/api.php I get error because -> Access-Control-Allow-Origin

Please, any solutions? I was using json api before, but when I build and upload to a hosting service (not node) I cant post on json.

0 likes
2 replies
KNietzsche's avatar

the last I created yesterday and works like a charm, was something like in web.php

Route::get('/search', function()...

and in my vue something like that

axios.get('search?q='+this.asearch)
            .then

Hope that helps even if you don't use axios....

Please or to participate in this conversation.