laravel - how to hit an api on button click using laravel
问题描述
i am new to working with API ,i have 2 buttons in my view file and i want to print the sheet which is available as an API ,
<div class="card">
<div class="card-body">
@include('admin.inc.messages')
<div class="row justify-content-center">
<div class="col-md-4">
<button type="button" class="btn btn-primary btn-block">Back</button>
<button type="button" class="btn btn-primary btn-block">Print Airway Bill</button>
<button type="button" class="btn btn-primary btn-block">Print Invoice</button>
</div>
</div>
</div>
</div>
i have got the path , i want to ask where should i define the path for that , in the web.php or api.php and second thing how should i give the path in the buttons
any help will be appreciated !
解决方案
您很可能需要使用自己的 api,或者使用 ajax 请求。这可以通过护照来完成,在文档中可以看到。如果您愿意,您可以随时绕过,但是您将无法使用中间件处理这些请求。这意味着,您的项目将面临潜在的安全风险,因为请求不会受到路由中间件的影响。在某些方面保护和帮助您。
例如,如果您无法针对中间件进行身份验证,您将无法确定哪个/什么用户正在请求数据。另一个比较可能是针对用户登录的能力,但无法通过应用程序页面知道哪个用户已通过身份验证。这与您登录 stackoverflow 时的情况相当,您显然可以在右上角看到您的用户信息/个人资料以及您的图片等……如果您绕过,您将没有该能力。
因此,我强烈建议您访问上面发布的链接,并考虑使用您自己的 api 或创建一个服务来这样做。
推荐阅读
- android - 仅在 Android 中的 Tensorflow .pb 文件就足够了
- c# - 使用 WebClient 发布对负载平衡 Wcf Rest Api 的调用有时会出现异常
- database - 具有来自另一个表的条件的数据库约束
- css - 触发单选按钮的选中选择器后是否可以更改 CSS 变量?
- django - 更改 DRF 路由器中的查找正则表达式
- python - Minimax 函数为井字棋中所有可能的移动返回相同的评估
- python - 修补从模拟类调用的类函数
- python - 如何从 JSON 文件中删除键/对象?
- javascript - Gatsby Remark 用于画廊、视频、学分等的边车文件?
- php - PHP将值推送到键的子数组中