Solve the problem that the WeChat applet cloud development model cannot obtain database data

Solve the problem that the WeChat applet cloud development model cannot obtain database data

problem:

There are two pieces of data in the database, and nothing happens in the output window when the data is obtained.
Insert picture description here
Insert picture description here
Insert picture description here

wrong reason:

  1. Check whether the database name corresponds
  2. Check if you have multiple cloud development environments.
    If you have multiple cloud development environments, you need to specify the environment. Otherwise, your first development environment will be selected by default. At this time, the environment where the data is created is inconsistent with the environment you read. The above non-response problem.
    Insert picture description here

solve:

Enter the name of the environment where you store the data in env in app.js, save it, and
Insert picture description here
run at this time
Insert picture description here

New problem

There is a response but there is no data at this time. This is because you have not opened all human-readable permissions in the database permissions.

Solve new problems

Find the cloud development console and change the data permissions to be readable by all users, only the creator can read and write, just save it
Insert picture description here
and run again at this time
Insert picture description here

To access the database

Insert picture description here

Guess you like

Origin blog.csdn.net/zjlwdqca/article/details/112024762