Best practice when building both RESTful API and web application [closed] - json

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
So i'm developing a project using Laravel 5.7, and I want to include a RESTful API to make the mobile version communicate with the app, and of course the web application itself.
My question is, what is the best practice is such cases when it comes to routing and controllers, I have read some suggestions here and other blogs and got confused, some suggested that I should declare One Routing file to be used by the web app and API and add an identifier for e.g("web" and "mobile") and based on it I return a view or JSON data, others suggested to separate the routing (api and web) but point them to the same controller methods which is think it's better than the first suggestion.
Appreciate your help.

Laravel separates the api routes from the web routes.
Web routes are in the routes/web.php file.
API routes are in the routes/api.php file.
What can be annoying is to separate the logic of the API part from the logic of the web part.
Here the solution is still simple. What I do is I create a folder that I call API in app/Http/Controllers; all the controllers I put in this folder are in the App\Http\Controllers\API namespace. In the corresponding route file, all you need to do is add the API\ flag before the controller name.

Related

Where to Start Flutter Backend Development? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am new to flutter and programming as well.
I am following flutters official docs and have sailed smoothly till State Management.
After that it has section for networking https and json serializing.
here
I have no idea about backend and networking and json please help me or guide me how to connect and access servers for my app.
Don't worry!
First, you need to learn a bit of JSON and Rest API
Here is a random tutorial
https://www.smashingmagazine.com/2018/01/understanding-using-rest-api/
Hope it's good) or google it yourself "what is JSON rest API"
What you need to know that there is no "Flutter specific backend" there is an app and the server and most popular way to communicate is Rest API.
Second, you will need to learn How to send a request and receive a response from the server. Hope its in your tutorial and after understanding what is Rest API and JSON it will make sens to you.
But there are great flutter official docs about that
https://flutter.dev/docs/cookbook/networking/fetch-data
Finally Firebase It's wonderful, thanks to google for it, it provides you a server for your app for free (at least when there are no too much of real users), It will save you a lot of time and money because it provides easy to use free servers that require minimum knowledge of backend
you can start with with packages for basic http request : https://pub.dev/packages/http

Connect Vue.js and laravel [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Greeting developers, I am a university student and really new to using frameworks. Currently, i done one project for my intern using laravel framework for back end.
Now i plan to do front end using vuejs framework.May i know how to connect the back end and front end. I see previous question in stack overflow there mention can connect using Rest api. May i know how it can happen.Furthermore, i also want to know which is better front end framework for laravel based back end framework angularjs or vuejs.
<html>Thanks in advance</html>
To "connect" your app to a backend service (whatever Laravel/Express/RoR etc), you have to make HTTP calls to your backend server.
With VueJS, you can use Axios to make HTTP calls.
Example of usage:
axios.get('https://yourbackend.io/users/all').then(users => {
this.users = users;
});
About your last question, there's no "best framework" to use/learn along with any backend technology. However, if you want to see good resources for Laravel and VueJS, you can watch Laracast videos.

Having HTML markup as part JSON response, is it a best practice? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Is it a good practice to have html markup as part of API response? which has the content-type as application/json
Sample json response
{
html : '<div id="markup">This is the server response html.</div>',
data : {property : 'This is the data received from the server.'}
}
It's not best practice.
Generally, you want to create a separation of concerns within your systems. By having your API return HTML, your server starts to take some responsibility for the presentation layer of your application as well as providing the data.
Think about what would happen if in future, you want to build a mobile app using your server. It wouldn't be able to effectively make use of the html property. Would you add a separate property that gets used by the mobile app? You don't want to keep changing your API server each time a new client wants to use it.
Think about what happens if you get a designer on to help you with your application. They now need the ability to modify code on the API server as well as the web layer. If you keep presentation of the data separate to the raw data, you won't run into this problem.

Redmine REST API -client-server [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My boss told me to create a REST API using html/css but i'm copletely blocked..
How can we create Redmine RESTful API using html ?
You can't create a REST API only with html. A REST API means that you defines a "resource" and you utilize the HTTP (usually) protocol in order to change the "state" of the resource. For example: the resource is http://example.com/a. You can make a GET request in order to get this resource, POST for changing it and DELETE for deleting it.
As you can see, it's a work with the server and not with the content that the client sees (html) - You need a server-side language, like: Python, Java, Php, etc.
Please tell us if you know a server-side language and we will be able to tell you how you can program a REST API in that language.

FileMaker + Ruby + HTML + eBay: Any way to upload listings as HTML? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I work for a small business that does a lot of commerce via eBay. Right now, we have a pretty large database (in FileMaker), and our current method for getting newly-entered items from the database to eBay involves entering them manually, line-by-line, through a browser window into Auctiva. This is an extremely time-consuming process, and I've been tasked with automating it, if possible I've already written a good bit of code in Ruby to parse tab-delimited FileMaker exports into pretty much whatever I want, so I was wondering if there was some way to upload static HTML directly into an eBay listing. If so, I could just snag a spiffy HTML template from oswd, modify it, and modify the code I've already written to handle injecting the pertinent info directly into the document, then just upload that.
If you can do whatever with the product data, and have all the data necessary to make a listing, you can use the eBay API.
http://developer.ebay.com/products/trading/
has a HTTP POST based submission handler so you can use any http client you want (Net::HTTP, HTTP party, Curb etc) and post your listings that way.