I’m creating an API for my mobile app with Laravel – Lumen and i have the following scenario which i don’t know what is the most sufficient way to return the response to my Android / IOS App,
lets assume that the user is trying to sign in (same end point):
Case 1 : the user provide the correct data for the sign in.
Case 2 : the user sign in with wrong password.
Case 3 : the user is not exist and have to sign up first.
My question is what should my API response look like in order i can differentiate those cases in my App logic and to move forward accordingly (I need to know which case is occurred ) ?
Advertisement
Answer
Your response would be below –
Use this response if request validated successfully. {"status":"OK", "message":"success"} Use this response if user not exist. {"status":"FAIL", "message":"not_register"} Use this response for invalid credentials. {"status":"FAIL", "message":"invalid_credentials"}