Skip to content

akmamun/react-api-integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React API Integration with example of Fetch Axios

List of Todo API Routes

Request Endpoint Details Example Source
GET http://127.0.0.1:5000/todos Get All API
GET http://127.0.0.1:5000/todos/todo_id Get Single Id API
POST http://127.0.0.1:5000/todos Insert One API
PUT http://127.0.0.1:5000/todos/todo_id Update One API
DELETE http://127.0.0.1:5000/todos/todo_id Delete One API

In Api File Define all routes

apiUrl = "http://127.0.0.1:5000/api/v1/"; todos = apiUrl + "todos"; todos() { return { getOne: ({id}) => axios.get(todos + `/${id}`), //url, id getAll: () => axios.get(todos), //url create: (data) => axios.post(todos, data), //url, data update: (toUpdate) => axios.put(toUpdate), delete: ({ id }) => axios.delete(`${id}`) } } ```js api.todos().getAll()

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •