I created plugin, installed, activated, and is availabe under settings=>extentions=>custom module
now i want to submit a form with post method, its done here in EoTestPlugin/src/Resources/app/administration/ser/module/swag-example/page/swag-example/index.js
onSubmit() {
console.log(‚submit‘);
let formData = new FormData();
formData.append(‚csvFile‘, this.$refs.csvFile.files[0]);
const article = { title: „Vue POST Request Example“ };
axios.post(‚/testplugin/uploadcsv‘, article)
.then(response => {
// Handle success
console.log(‚Success:‘, response);
})
.catch(error => {
// Handle error
console.log(‚Error:‘, error);
});
}
EoTestPlugin/src/Storefront/Controller/TestPluginController.php
route only
/**
* @Route(„/testplugin/uploadcsv“, name=„api.action.test-plugin.upload-csv“, methods={„POST“})
*/
i also want to mention that i tried with same route in EoTestPlugin/src/Controller/Api/TestPluginController
routes.xml
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
https://symfony.com/schema/routing/routing-1.0.xsd">
<import resource="../../Storefront/Controller/**/*Controller.php" type="annotation" />
<import resource="../../Controller/Api/**/*Controller.php" type="annotation"/>
<!-- <import resource="@EoTestPlugin/Controller/Api/TestPluginController.php" type="annotation" /> -->
</routes>
service.xml
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="Eo\TestPlugin\Storefront\Controller\TestPluginController" public="true">
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
</service>
<service id="Eo\TestPlugin\Controller\Api\TestPluginController" public="true">
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
</service>
</services>
</container>
as you can see i have console.log(‚submit‘); in onSubmit func and it works but when it hits axios i get:
POST http://swtasks.local/testplugin/uploadcsv 404 (Not Found)
./bin/build-administration.sh and bin/console cache:clear were both executed
This is my first task in Shopware, and i am using latest version.