Is it possible to do this node.js code with .NET?

I really need help and i would apreciate if someone can help me with this I need to do the same than here but with .NET, instead of node js. I never worked with .NET before.

Is my first time working with tokens and APIs. So i kinda need help with this

Question: Is it possible to do this with .NET? if it’s not possible, i would like to know it. thanks.

UH API Behavior - Error handling

. Sample API request with retry for refreshing the token (if the app is using axios and MSAL.js).

get: async (url, retry = true) => {
        const _url = url;
        const headers = {
            Authorization: `Bearer ${sessionStorage.getItem("user_token")}`
        };
        const _retry = retry;
        const axiosInstance = axios.create({
            headers,
            responseType: "application/json"
        });
        axiosInstance.interceptors.response.use(
            (res) => {                return res;
            },
            async (error) => {
                // debugger;
                const status = error.response ? error.response.status : null;
                if (status === 401 && _retry) {
                    sessionStorage.removeItem("user_token");
              const hasToken = await  refreshToken();                  
                        return httpClirefreshTokenentServiceWithRefreshToken.get(
                            _url,
                            false
                        );                    
                }
                return Promise.reject(error);
            }
        );
        return new Promise((resolve, reject) => {
            axiosInstance
                .get(_url)
                // .post(url, data, headers)
                .then((response) => {
                    if (response.status === 200) {
                        resolve(response.data);
                    } else {
                        resolve(response);
                    }
                })
           

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.