X
X
xcuube2019-07-21 17:55:56
Slim Framework
xcuube, 2019-07-21 17:55:56

How to interact with slim framework from vue?

Hello! The question is probably stupid, but I can not figure out how to get data from slim from vue.
For example, there is such a code of the index.php file in the server folder

<?php

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require '../../vendor/autoload.php';

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
    $name = $request->getAttribute('name');
    $response->getBody()->write("Hello, $name");

    return $response;
});
$app->get('/hi/{name}', function (Request $request, Response $response) {
    $name = $request->getAttribute('name');
    $response->getBody()->write("Hello, $name");

    return $response;
});
$app->run();

And such vue method code
test: function(){
                axios.post('server/hello/anton', {
                }).then(response => {
                    console.log(response.data);                    
                });
            },

When working, the test method gives a 404 error.
In general, please help me figure out where to send axios to get a response from slim.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question