2 year experienced ReactJs Mock Interview | 🎉 Selected | ReactJs & JavaScript | Tier 2/3 college

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 81

  • @qurashishebi7988
    @qurashishebi7988 Рік тому +4

    I think we used axios interceptor to track the response of request and if it is failed then we need to automatically call another request to refresh token and then automatically call the original request and user don't know about that. So in that case user experience is also improved.

    • @careerwithvasanth
      @careerwithvasanth  Рік тому

      How you're making everything "Automatic" ? can you elaborate ?

    • @qurashishebi7988
      @qurashishebi7988 Рік тому

      @@careerwithvasanth actually interceptor is used to track the response of every request and if response status is 401 then we request on refresh token end point but failed request store and after refresh token we call it again

  • @AllAboutReactJs
    @AllAboutReactJs 7 місяців тому +4

    Your interviews are insightful, I would recommend answering the questions as well if its not answered correctly.

    • @careerwithvasanth
      @careerwithvasanth  7 місяців тому +1

      Noted your suggestion !! will try to do it, in future videos

    • @abhishekporwal876
      @abhishekporwal876 6 місяців тому +2

      @@careerwithvasanth yeah please, correct the answer if candidate give wrong answer, it will be helpful to know us also when we are also think what could be the answer and candidate give wrong answer, we can match it with your answer.

    • @careerwithvasanth
      @careerwithvasanth  6 місяців тому

      @@abhishekporwal876 Thanks for the comments!! if you checkout new videos on the same playlist I'm answering all the questions at the end !!ua-cam.com/play/PLmcRO0ZwQv4SwXLVpnKb_nFQx1Wd2XEjD.html

  • @piyushpatil9359
    @piyushpatil9359 Рік тому +2

    I have 2 approaches that i used...
    1) if it got status code in response 401 then I'll simple logout and tell user to login again with new token
    2) If there is a support of refresh token from Backend then I'll use axios interceptor...when i make parallel api calls and first time my token gets expire then that time i got some error for that api call...then I'll call another api using interceptor and get refresh token replace that token with my current expired one token and move forward with that refresh token...

  • @miw879
    @miw879 Рік тому +11

    It would be better if you could answer the questions he was not able to give answer to anyways its a mock us audience will get to learn as well

    • @careerwithvasanth
      @careerwithvasanth  Рік тому +2

      Miw, I too want to do that !! but video becomes lengthy, for any question you don't get the answer online, comment here. I will try to answer them !!

    • @miw879
      @miw879 Рік тому

      @@careerwithvasanth great thanks we can start with how to make that prototype map function available across your entire app?

    • @vasu7370
      @vasu7370 Рік тому

      @@miw879 exporting it and importing it

    • @miw879
      @miw879 Рік тому

      @@careerwithvasanth still waiting for your reply sir

    • @careerwithvasanth
      @careerwithvasanth  Рік тому

      @@miw879 Hi, sorry for late reply. Join our 1800+ member uncommon geeks telegram group here, you can discuss such queries there
      t.me/uncommongeek install telegram app on your mobile and click this link.
      I have less time to make video about it, but you can clarify all your doubts on this group.

  • @Jay_Patel2000
    @Jay_Patel2000 6 місяців тому +1

    We can solve using the wrapper function to check the token is expired or not, we can simply create a guard auth file for check always token expire or not if we get incorrect response we can logout the user and redirect to the login page, I have implemented that with jwt token

  • @Pankaj-nr1pw
    @Pankaj-nr1pw Рік тому +2

    Good way to get insights about React interview. The way to ask and answer questions is amazing.

  • @ambrishsukla3036
    @ambrishsukla3036 Рік тому +4

    Question 3 - We can implement a function of refrshToken, wheich will check whether session is active or not, and based on that status we will execute other 3 api's.
    if status is true then 3 api will be called else getNewToken will be executed, and then will use new toekn for other 3 api's.
    Please Do let me know whether answer is corret or not?

    • @careerwithvasanth
      @careerwithvasanth  Рік тому

      How to invoke refreshToken ? from each of the 3 API's or ?

    • @yuvraj5283
      @yuvraj5283 Рік тому

      Can use axios and it's concept interceptor,
      What will happen is when acces token expired interceptor listens that acces token expired and after that it calls the refresh token api to get the new token and after all 3 api will call with new token.
      Interceptor.request
      Interceptor.response

    • @economics11th16
      @economics11th16 Рік тому

      The same question asked to me, and I answered that I will create a separate function. But at that time I was not sure that it's a right way to do this or not but I was right.

  • @adityapundir6529
    @adityapundir6529 Рік тому +2

    If the first call succeeds, I'm gonna set the state to proceed for other calls, and in useEffect, if the state tells to proceed, I will. Else, I'm not gonna continue for those calls.

  • @syedimam1998
    @syedimam1998 Рік тому +4

    At 13:38
    How about using token refreshing with a lock mechanism?

  • @adityapundir6529
    @adityapundir6529 Рік тому +3

    The myMap function can be exported and then can be imported wherever needed

  • @sanchitasuryavanshi674
    @sanchitasuryavanshi674 Рік тому +1

    Solution for 15:00 use async await

  • @SathishS-y3z
    @SathishS-y3z 10 місяців тому +1

    very good real life interview experiance

  • @nikhilranjankumar6069
    @nikhilranjankumar6069 Рік тому +1

    When we land on a website we check that we have fetch one api that tells about whether the user is logged in or not if the user is logged in then we definitely have the token else we logged out the user and prevent us to call another api.
    So like we have a social media web app so in this we will fetch the user profile where we get the token and save it to local storage ... If we have the Authorization token in then only we logged in the user else users have to log in again we can easily achieve this using the backend ....
    So now the other api call will depend upon if we have a profile or not ...
    So if we have a profile and we have the correct token and we proceed else the user has to login in again the token renew

    • @careerwithvasanth
      @careerwithvasanth  Рік тому

      There are 2 things here, authorisation token and access token. Authorisation token will be present if user is logged in, where as access token will expire at some predefined interval. So user is logged in (as authorisation token is valid) but access token is expired. How do you handle that situation is my question !!

    • @shubhanshusahuu
      @shubhanshusahuu 6 місяців тому

      ​​@@careerwithvasanth can send this access token to all the protected routes inside their headers,
      which needs to be called only when the access token is valid,
      On the backend they can verify that is access token is valid or not.

  • @allindiachannel2290
    @allindiachannel2290 Рік тому +1

    In the question of 3 api parallel call -> i think promise channing should be a solution first we check if the fisrt api call is resolved then return to next two unless go in the catch block

    • @careerwithvasanth
      @careerwithvasanth  Рік тому

      Promise chaining is not parallel execution, it's a concurrent execution.

    • @allindiachannel2290
      @allindiachannel2290 Рік тому +1

      @@careerwithvasanth Sir where can i read about parallel and concurrent execution of javascript? Can you give me the link?

    • @careerwithvasanth
      @careerwithvasanth  Рік тому +2

      ​@@allindiachannel2290 Join our group here: t.me/uncommongeek you will get a community of people who can help you with all these !! open link from mobile phone after installing Telegram application.

  • @Prince-yz1tc
    @Prince-yz1tc 5 місяців тому

    I'll have a variable to set if any api call fails. If it fails, i'll cancel out the parallel calls made to rest two calls.

  • @Nikhilkumar-yh7yc
    @Nikhilkumar-yh7yc 5 місяців тому +1

    Promise.all will be used . it means if token get fail it will return the failure

    • @careerwithvasanth
      @careerwithvasanth  5 місяців тому

      Promise.all will execute all promises in concurrent and the problem I asked cannot be solved by it.

  • @abhishekkumarsingh5615
    @abhishekkumarsingh5615 11 місяців тому +1

    Sir can you also give the answers to few of the questions. That will make us learn quickly.

    • @careerwithvasanth
      @careerwithvasanth  6 місяців тому

      Thanks for the comments!! if you checkout new videos on the same playlist I'm answering all the questions at the end !!ua-cam.com/users/playlist?

  • @fardeenmalnas3203
    @fardeenmalnas3203 Рік тому +2

    17:05 can we use cookies to store user auth token then check using if else condition if user auth token is expired then do 1 api call
    Else do all 3 api call

    • @careerwithvasanth
      @careerwithvasanth  Рік тому +1

      How to do handle parallel API calling ??

    • @fardeenmalnas3203
      @fardeenmalnas3203 Рік тому +2

      @@careerwithvasanth we can use promise.all() for parellel api calls.
      Please correct me if i am wrong

  • @yogeshchaurasiya8915
    @yogeshchaurasiya8915 Рік тому +2

    Can please share candidate resume.

  • @kalashnikov203
    @kalashnikov203 Рік тому +1

    Sir can u please explain the solution to prevent parllel api calls in case of expired tokens problem , Not able to find the answer anywhere not even in telegram channel, especially to prevent other two api calls after the initiation of first api call, most the solutions are for preventing all the api calls but not after first api call since they run in parallel all are initiated one after other without waiting for the result of first api call.

    • @Dhirajkumar-fb3to
      @Dhirajkumar-fb3to 8 місяців тому

      Bro as i think promise have some methods for this like promise.All(api1,api2,api3) which give all the resp. For the condition that even 1 will give the resp it's race() ,is settled() 4-5 methods are there i think this one of them will be use here

  • @nallaparajuamareshvarma8471
    @nallaparajuamareshvarma8471 Рік тому +2

    Can any one tell me where to place the poly fills folder in react.js

    • @careerwithvasanth
      @careerwithvasanth  Рік тому

      Generally people don't create polyfills in ReactJS project. They just use utilities to do the required functionalities

  • @Dhirajkumar-fb3to
    @Dhirajkumar-fb3to 8 місяців тому

    Bro useReducer make it more complex, it's for heavy complex state Mangmt altr of useState if you want to use useReducer go with the redux, .. It's have smiliar syntax of that

    • @Dhirajkumar-fb3to
      @Dhirajkumar-fb3to 8 місяців тому

      May be im wrong but sallow copy malfunctuonality will help here to change the original object if you like to do so.. Or if you want to create new obj go with the deep copy..

  • @MrPurpleBOT9547
    @MrPurpleBOT9547 Рік тому +1

    I think we could do that token question with maintaining redux or usecontext api
    We will check for token expiry for all apis and when we got valid token then we will maintain it in context and we will check for that context before hitting api if we get false for that context we can hit the api or we will return it with some response
    Please share your thoughts on this solution it would be really appreciated 🙏

    • @careerwithvasanth
      @careerwithvasanth  Рік тому +1

      How do you handle the requests that are not processed because of token expiry ? how to re-trigger it ?

    • @MrPurpleBOT9547
      @MrPurpleBOT9547 Рік тому

      @uncommongeeks okay for that i am maintaining the context in boolean when the first requests hit and git the error of token expiry i will set the context to true and when i got the data from that requests i will set the context value to false and i will put a check on top for every query to first check the context value before hitting the request.

    • @MrPurpleBOT9547
      @MrPurpleBOT9547 Рік тому

      If the context value is false then we could go for the next step of hitting api

    • @MrPurpleBOT9547
      @MrPurpleBOT9547 Рік тому

      Share your review on this

  • @SanjayYadav-ur4qj
    @SanjayYadav-ur4qj Рік тому

    Since you are making API requests parallelly. How can you check that the first call has failed and now I have to put the second call in the queue meanwhile the token is being refreshed? Both will make requests to the server simultaneously (approx.) and will be failed.

    • @abhishekdharamkar5294
      @abhishekdharamkar5294 10 місяців тому

      if api call fail due to expiration of token then it should redirect to login page and empty the localstorage

  • @thirukumaran7294
    @thirukumaran7294 Рік тому +1

    can we use any interceptors so that if the token error showed up , then we can cancel other 2 apis??

    • @careerwithvasanth
      @careerwithvasanth  Рік тому

      That's partially right !! but how to you handle re-calling those 2 API's ??

    • @thirukumaran7294
      @thirukumaran7294 Рік тому

      @@careerwithvasanth dont have any idea bro, please spit it from ur mouth 😃

  • @hello_Subham
    @hello_Subham Рік тому +1

    Hello sir I m interested in a mock interview I have knowledge of frontend technologies.

    • @careerwithvasanth
      @careerwithvasanth  Рік тому +1

      Follow me on LinkedIn www.linkedin.com/in/vasanthbhat/
      Join our telegram group here t.me/uncommongeek
      Message me in either of the two(Preferably telegram) and we can connect for a mock interview..

  • @bandaumamahesh9346
    @bandaumamahesh9346 8 місяців тому +1

    Sir can you please suggest any good books for learning frontend developer

    • @careerwithvasanth
      @careerwithvasanth  6 місяців тому

      Hi, Join our 3100+ member Career with Vasanth telegram group here, you can discuss things like this and a lot of opening related information is also shared here: t.me/uncommongeek

  • @awais_ansarii
    @awais_ansarii Рік тому +1

    ❣️

  • @siddhartharaja9413
    @siddhartharaja9413 Рік тому +1

    Great

  • @anushasurakala5975
    @anushasurakala5975 8 місяців тому

    thankyou

  • @puneetmeena1893
    @puneetmeena1893 4 місяці тому

    arvind bhaiya😂😂😂😂😂😂

  • @sohanYT69
    @sohanYT69 Рік тому +1

    if (isTokenExpired(authToken)) {
    return refreshAuthToken()
    .then((newToken) => {
    // Now we have the new token, make the parallel requests
    return Promise.all(
    urls.map((url) => fetchWithToken(url, newToken))
    );
    });
    } else{
    return Promise.all(
    urls.map((url) => fetchWithToken(url, newToken))
    )}}
    isnt this the ryt way? or am I missing something?

    • @careerwithvasanth
      @careerwithvasanth  Рік тому

      If you can add code sandbox link that would be easy to validate

  • @manojkumarsahoo1905
    @manojkumarsahoo1905 Рік тому +1

    I think we can do by promise.race

    • @careerwithvasanth
      @careerwithvasanth  Рік тому

      Can you please add the code snippets ? appreciate your comments.

  • @MessiLeo2312
    @MessiLeo2312 Рік тому +1