简体   繁体   English

使用 php 和 axios 反应本机连接到本地数据库

[英]React native connect to local database with php and axios

I'm having a problem connecting the front-end to the back-end through PHP.我在通过 PHP 将前端连接到后端时遇到问题。 The database is connected with PHP but not the front-end, and when I run it on the Postman, it prints out 500 internal server error.数据库连接到 PHP 但不是前端,当我在 Postman 上运行它时,它会打印出 500 internal server error。

    axios
      .get(Api, {
        params: {
          route: "extension/account/purpletree_multivendor/api/sellers",
          language_id: this.props.language,
          search_text: this.state.searchTxt.toUpperCase(),
          category_id: categoryId.toString(),
          geocode: geocode,
        },
        headers: {
          'Content-Type': 'application/json',
        },
      })
      .then((res) => {
        //handle no seach item
        if (res.data.success) {
          if (res.data.message !== "No Data") {
            this.setState({
              sellers: res.data.data.sellers,
              isLoading: false,
            });
          } else {
            this.setState({ isLoading: false, showMessage: true });
          }
        } else {
          //show error message
          this.setState({ isLoading: false });
        }
      });

Thank you for answering this question, I have asked an instructor of mine and figured:感谢您回答这个问题,我问了我的一位导师并想通了:

  1. I did not turn on the display_errors in php.ini我没有打开 php.ini 中的display_errors
  2. After turning it on it prints out the detailed error, which is some of my database tables are missing, so it won't be able to run.打开它后,它会打印出详细的错误,这是我的一些数据库表丢失了,所以它无法运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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