Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Example of a react-redux frontend using redux-axios-middleware that calls a .NET Core Web API

NotificationsYou must be signed in to change notification settings

Odonno/react-redux-axios-middleware-netcore-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Example of a react-redux frontend using redux-axios-middleware that calls a .NET Core Web API

Front

The frontend is written in react with a redux architecture.Actions and reducers can handle APi calls thank to redux-axios-middleware.

Actions

Here is an example of a single action handling both request and response from the API.

Request action

{type:'API_CALL_NAME',payload:{request:AxiosRequestConfig}}

Response action

success action

{type:'API_CALL_SUCCESS',payload:AxiosResponse}

fail action

{type:'API_CALL_FAIL',payload:AxiosResponse}

Reducers

Request reducer

In general, you should avoid using request reducer to update the state.

Depending on your use cases, request reducer can be directly used to give the feeling that the request has already been handled by the server. In case it doesn't, the FAIL action should be used to alert the user that there was a failure.

caseActions.INCREMENT:return{        ...state,values:state.values.map(v=>{if(v.name===action.payload.request.data.valueName){return{                    ...v,value:v.value+1};}returnv;})};

Response reducer

caseActions.GET_VALUES_SUCCESS:return{        ...state,values:action.payload.data};

Back

The backend is written using ASP.NET Core. It simply contains API routes used by the frontend.

Example 1 : counter with increment/decrement actions

Example of a web app that use simple API requests : increment or decrement named values.

About

Example of a react-redux frontend using redux-axios-middleware that calls a .NET Core Web API

Topics

Resources

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp