在移动应用程序中对我的所有请求使用$ http.post是否可以?

在移动应用程序中对我的所有请求使用$ http.post是否可以?

问题描述:

I am building a ionic app that interacts with my PHP backend. Each of my calls to the API are made with $http.post and I retrieve the data as json in my php scripts.

Is this fine or will this cause any problems for the future?

我正在构建一个与我的PHP后端交互的离子应用程序。 我对API的每次调用都是使用$ http.post进行的,我在php脚本中将数据检索为json。 p>

这样可以,还是会导致将来出现问题? p> div>

This will work, as long as you consider the following things:

  • sending everything as "POST" might confuse developers. Speaking in REST terms, POST is send when creating something new on the server. GET is used to read something. PUT is used to update. And so on. For some clean code, you might consider making a difference here
  • What happens, if the user is offline? Is it a problem?
  • How many requests are happening? Many requests slow down your application, as the user has to wait.

You can think about offline support, caching data on the smartphone and similar things. People nowadays expect things like that.

i don't think so, i have my ionic app with a lot of services with $http.post request and i still not having problems.

Maybe the only one that will have problems just your backend for overload or something like that but not your app.

So i think you can continue coding your app :)

There is no harm. Your js code shoube be expressive and readable to other developers also. Use POST when you are writing or sending some information to the server.