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

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 พ.ย. 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 5 หลายเดือนก่อน +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  5 หลายเดือนก่อน

      @@abhishekporwal876 Thanks for the comments!! if you checkout new videos on the same playlist I'm answering all the questions at the end !!th-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...

  • @Jay_Patel2000
    @Jay_Patel2000 5 หลายเดือนก่อน +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

  • @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.

  • @Pankaj-nr1pw
    @Pankaj-nr1pw ปีที่แล้ว +2

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

  • @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.

  • @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 5 หลายเดือนก่อน

      ​​@@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.

  • @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.

    • @careerwithvasanth
      @careerwithvasanth  ปีที่แล้ว

      That's debatable as calls happen in parallel !!

  • @adityapundir6529
    @adityapundir6529 ปีที่แล้ว +3

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

  • @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.

  • @SathishS-y3z
    @SathishS-y3z 9 หลายเดือนก่อน +1

    very good real life interview experiance

  • @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 4 หลายเดือนก่อน

    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.

  • @abhishekkumarsingh5615
    @abhishekkumarsingh5615 10 หลายเดือนก่อน +1

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

    • @careerwithvasanth
      @careerwithvasanth  5 หลายเดือนก่อน

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

  • @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

  • @sanchitasuryavanshi674
    @sanchitasuryavanshi674 ปีที่แล้ว +1

    Solution for 15:00 use async await

  • @SanjayYadav-ur4qj
    @SanjayYadav-ur4qj 11 หลายเดือนก่อน

    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

  • @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

  • @bandaumamahesh9346
    @bandaumamahesh9346 8 หลายเดือนก่อน +1

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

    • @careerwithvasanth
      @careerwithvasanth  5 หลายเดือนก่อน

      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

  • @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 😃

  • @yogeshchaurasiya8915
    @yogeshchaurasiya8915 ปีที่แล้ว +2

    Can please share candidate resume.

  • @siddhartharaja9413
    @siddhartharaja9413 ปีที่แล้ว +1

    Great

  • @syedimam1998
    @syedimam1998 ปีที่แล้ว +4

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

  • @awais_ansarii
    @awais_ansarii ปีที่แล้ว +1

    ❣️

  • @anushasurakala5975
    @anushasurakala5975 8 หลายเดือนก่อน

    thankyou

  • @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..

  • @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

  • @puneetmeena1893
    @puneetmeena1893 3 หลายเดือนก่อน

    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