简体   繁体   中英

How send request to .php file(backend) from front end via fetch() or axios, then get some response like json object

我是 php 新手,我想使用 .php 文件作为 api,所以当我通过 fetch 或 axios 或任何其他方式从前端调用该 .php 文件时,它将以 json 格式返回数据.

有很多“假”api 来进行测试,这里是一个https://jsonplaceholder.typicode.com/

I think this solves your question, is to pass php data to front

I would change only the call to your path or php file

Returning JSON from a PHP Script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM