need help in laravel json nested array - view

im trying to pass json data from this url https://newsapi.org/v2/top-headlines?country=us&apiKey=8738ea79ad6d49afbd54abf75552c90b to view, but no work,is there any simple method to do this? thx
^

Related

laravel taking data with input function

i want to take data with input function in Laravel controller.
When i write dd($request->data) im getting this:
"_token=R58UyxNckoaiL0eFSIsd434343Gsh&name_surname=sdfsadf&telephone=0505"
I want to take name_surname
I tried this code
$request->data->input('name_surname')
but i can not get any data. its turning null. How can i get datas. If you help me i will be glad
you can access data sent from a form using $reqeust object using $request->input_name
so, to take name_surname and telephone
$name_surname = $req->name_surname;
$telephone = $req->telephone;
learn more from laravel doc(https://laravel.com/docs/8.x/requests#retrieving-input-via-dynamic-properties)
Also, validate user inputs before do anything
Try this code to make sure what are the inputs fields your are receiving and make sure input fields names
dd($request->all())
then try this
$request->field_name

How to reverse transform request from json api to proper data using Laravel, Lumen, Dingo, Ember Data?

I am using Lumen + Dingo + Ember JS
I am able to transform the response into JSON API. But when I post back the data from Ember, is it in same json api format. So I want to know is there any way to deform the json api data ?
data":{"attributes":{"size":2},"relationships":{"page":{"data":{"type":"pages","id":"2"}}},"type":"rows"}}
From above response, i want to get `size=2, pageId=2
I have properly used relationship in Lumen models.
Any idea, how can I achieve this?
P.s The question is about deformation of data from json api format, but not about json encode/decode.
if you are trying to decode in javascript then
JSON.parse(jsonString) // where jsonString is your string this will return parsed object in javascript
if you are trying to decode in php then
json_decode(jsonString) // will give you stdClass object

How to add objectId to array in Parse Core Data Browser

I am trying to create an array of objects within the Parse Data Browser, in my web browser. I was wondering how I would go about doing this?
Thanks
Looks like each Pointer is just a dictionary structure so the following works:
[{"__type":"Pointer","className":"yourClassName","objectId":"yourObjectsId"},
{"__type":"Pointer","className":"yourClassName","objectId":"your2ndObjectsId"}]

Passing nested objects in Polymer core-ajax

I am trying to pass a nested object to Polymer core-ajax. Here is the code:
<core-ajax url="DSPUser1.php" method="POST" on-core-response="{{responseventDSPUser}}" params='{"userID":"Anon", "transactionType":"DSPUser", "payload":{"id":"1"}}' handleAs="json" id="transactionDSPUser" response="{{msgout}}">``
When I look at the POST in the Chrome tools I see the following under Form Data:
userID:Anon
transactionType:DSPUser
payload:[object Object]
It looks as if core-ajax is not handling nested objects.
Is this a feature or a bug?
Should I be using body instead of params?
Regardless is there a way to pass a nested object using core-ajax?
PS When I use JQuery $.POST Chrome shows the following for Form Data for a similar request
transactionType:DSPUSER
userdID:Anonymous
securityToken:
payload[iD]:1
If Im not wrong, params are converted into queryString. For POST operations you should use body instead.

Cakephp -how to use and where to put debug($var) in $this?

I want to know the value of the associative array $this in cakephp, base on my research I could use debug($this);
however I don't know where to put it, model, view or controller, and I don't know where to see the result of debug($this);.
I'm trying to get the value of $this so that I can use them in making a rest api using json_encode.
To elaborate the process
Content or what is inside of $this(part which I want to see)
json_encode
ajax
any help suggestions or opinions is highly appreciated

Resources