• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

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

Sending status code in rest-api response

General Discussion
2
7
382
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 14 Aug 2024, 04:49

    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 14 Aug 2024, 06:25

      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 16 Aug 2024, 02:37 Reply Quote 0
      • M
        marshalbagisto @Rishabh-Webkul last edited by 16 Aug 2024, 02:37

        @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 20 Aug 2024, 13:10

          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 24 Aug 2024, 20:44 Reply Quote 0
          • M
            marshalbagisto @Rishabh-Webkul last edited by 21 Aug 2024, 02:43

            @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 24 Aug 2024, 20:44

              @Rishabh-Webkul Hi! Anything on this?

              1 Reply Last reply Reply Quote 0
              • Rishabh-Webkul
                Rishabh-Webkul last edited by 26 Aug 2024, 04:53

                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
                1 out of 7
                • First post
                  1/7
                  Last post