panthro
panthro

Reputation: 24099

Building an API with Laravel - data types?

Which data type is recommended when building an API with laravel?

Should all posted data be JSON? Should all server responses also be JSON?

I've never build an API before so I am a bit in the dark - a push in the right direction would be appreciated.

Upvotes: 0

Views: 39

Answers (2)

Akar
Akar

Reputation: 5415

Most modern APIs use JSON, because the front-end is always JavaScript, so if you have the response in JSON, then it would be way easier for the front end to deal with the data, since JSON is a (JavaScript Object Notation) anyways...

Pick JSON if you want to have less headaches in the front end.

Upvotes: 1

common sense
common sense

Reputation: 3912

JSON is not a data type but a representation of an object as the name already says JSON => Javascript Object Notation.

Data types are something like integer, boolean or string or your own ones. Which you use internally depends on your requirements.

Upvotes: 1

Related Questions