sr57's avatar
Level 39

dd for api?

dd (or dump) returns html code.

Is there a simple way to use them to debug an api function (json return)?

Thanks in advance.

0 likes
8 replies
tykus's avatar
tykus
Best Answer
Level 104

If you install (as a dev dependency) and run laravel dumpserver in your console, then you will see the dump or dd vars in the console - I find this better than the browser for dumped data.

Otherwise, check out Telescope.

Snapey's avatar

dd or dump will return json if you ask for json in you API request headers

1 like
sr57's avatar
Level 39

Thanks @snapey , logical, but we still had to think about it!

nulele's avatar

@Snapey I use axios in my Vue frontend and with this configuration, I stil get a 500 error when have a dd() in the controller:

  headers: {
    'Content-Type' : 'application/json',
    'Accept' : 'application/json',
  }

Please or to participate in this conversation.