uadmin: Data Access API Read does not work in JS
Greetings. I just want to say that Data Access API is one of the best feature ever so that I do not have to create an API file to access data. I accidentally found this from one of the closed issues. Fantastic!
http://localhost:8080/api/d lists all information related to Data Access API. I access http://localhost:8080/api/d/restaurant/read to read all Restaurant data.
{
"result": [
{
"ID": 1,
"DeletedAt": null,
"Name": "Burger King",
"Address": ""
},
{
"ID": 2,
"DeletedAt": null,
"Name": "Domino's Pizza",
"Address": ""
},
{
"ID": 3,
"DeletedAt": null,
"Name": "Subway",
"Address": ""
},
{
"ID": 4,
"DeletedAt": null,
"Name": "Panda Express",
"Address": ""
}
],
"status": "ok"
}
but performing in JS, i got this error
{
"err_msg": "Permission denied",
"status": "error"
}
Any advices please?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 20 (1 by maintainers)
I found the reason why. If your account is not logged in the uadmin page, you will get an error. That means you need to login your admin account first so that you can read data in JS.
There are so many questions to think about in the bigger picture. At least you discovered the secret treasure of uadmin.
thank you @dxlvgcw. could be better if we have more examples than my references I have. i will leave more questions here
i would request @Spotlight64 to reopen this issue
@alphakitchown Use APIPublicRead model method. Return the value to true to enable public access. Place it below your type struct inside your model file. Instead of *Model, replace it with the name of your struct.