How to make a REST API first web application in Laravel

后端 未结 6 1611
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 15:43

I want to make an API first application in Laravel. I don\'t know what is the best approach to do this, I will explain what I am trying to do, but please feel free to give a

6条回答
  •  盖世英雄少女心
    2020-12-07 16:40

    I have a response to the problem you are having with the Response. You can get the headers, status code and data from the Response.

    // your data
    $response->getData();
    
    // the status code of the Response
    $response->getStatusCode(); 
    
    // array of headers
    $response->headers->all();
    
    // array of headers with preserved case
    $response->headers->allPreserveCase(); 
    

    $response->headers is a Symfony\Component\HttpFoundation\ResponseHeaderBag which inherits from Symfony\Component\HttpFoundation\HeaderBag

提交回复
热议问题