dongyupan4850 2017-03-10 13:03
浏览 153
已采纳

来自本地PHP的Axios GET只返回代码而不是执行

The API I am trying to access has disabled CORS so I need to request on the server side. Utilizing React and Axios I am making a get request to the local php file which should execute cURL but am just getting the php code back instead of it executing

<?php $curl = curl_init();

curl_setopt($curl, CURLOPT_URL, "https://api.darksky.net/forecast/myAPIKet/coords");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);

curl_close($curl)

echo $result;
return;
?>

<script>
let info = axios.get('./proxy.php')
    console.log(info.data);
</script>

When this runs just the php code is logged in my console instead of the php script triggering and echoing the data I want.

  • 写回答

1条回答 默认 最新

  • duannaoben8011 2017-03-10 14:55
    关注

    Sounds like your environment hasn't got PHP installed.

    Do you have anymore information about it?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 slam rangenet++配置
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊