Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Sending status code in rest-api response

    General Discussion
    2
    7
    380
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      marshalbagisto last edited by

      Hello Everyone,
      I have installed the rest-api to serve the APIs to the frontend application. The res-apis only send the message in return of the success API and some big json in return of the failure. How can I send the status codes with the response so that frontend dev knows which kind of response if this?
      Please share a way in which I do not loss my changes when I update the Bagisto and Dependencies in future.
      Thank you

      1 Reply Last reply Reply Quote 0
      • Rishabh-Webkul
        Rishabh-Webkul last edited by

        Hello @marshalbagisto

        We are using normal status codes like

        1) 200 for all successful responses.

        2) 422 for validation errors.

        3) 500 for server errors

        And if you need to add more key then you need to customize it at your end.

        Or we can do it for you as a paid service for this you can purchase our hourly package,

        https://store.webkul.com/bagisto-hourly-customization-package.html

        Thanks & Regards

        M 1 Reply Last reply Reply Quote 0
        • M
          marshalbagisto @Rishabh-Webkul last edited by

          @Rishabh-Webkul Hi! I am not receiving even basic status codes in response. Can you please guide if I am using something wrong?

          1 Reply Last reply Reply Quote 0
          • Rishabh-Webkul
            Rishabh-Webkul last edited by

            Hello @marshalbagisto

            Can you provide us with a screenshot of the query and the response of the API

            Thanks & Regards

            M 2 Replies Last reply Reply Quote 0
            • M
              marshalbagisto @Rishabh-Webkul last edited by

              @Rishabh-Webkul Please check the screenshot screenshot-engi-nerds.postman.co-2024.08.20-22_40_59.png

              1 Reply Last reply Reply Quote 0
              • M
                marshalbagisto @Rishabh-Webkul last edited by

                @Rishabh-Webkul Hi! Anything on this?

                1 Reply Last reply Reply Quote 0
                • Rishabh-Webkul
                  Rishabh-Webkul last edited by

                  Hello @marshalbagisto

                  Status Codes are not sent inside the response they were handled by Laravel and Axios

                  For 200 - return response()->json([|

                  'data' => $categories

                  ], 200);

                  For 500 - return response()->json([|

                  'message' => 'Someting went wrong'

                  ], 500);

                  and in your screenshot, we have marked, that your status code will be visible at this point as shown in the image below.

                  rtmmti.png

                  Thanks & Regards

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post