Skip to content

The Dallas Cowboys Roster Editor is a full CRUD React app to update the Dallas Cowboy Roster API I created for the Dallas Cowboys Calculator that I also created.

Notifications You must be signed in to change notification settings

Darnycya/dallas-cowboys-roster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dallas Cowboys Roster Editor

The Dallas Cowboys Roster Editor is a full CRUD React app to update the Dallas Cowboy Roster API I created for the Dallas Cowboys Calculator that I also created.

Link To Editer

Click Here

Sample of API

{
_id: "604ac20fb4f40e9ebaff5b88",
name: "Dak Prescott",
image: "https://res.cloudinary.com/darnycya/image/upload/v1615357339/Dak_Prescott_4_c5tdat.png",
position: "Quarterback",
jerseyNumber: 4,
__v: 0,
createdAt: "2021-03-12T01:21:19.372Z",
updatedAt: "2021-03-12T01:21:19.372Z"
}

Sample of the CRUD Frunctionality

import axios from 'axios'

const apiUrl = `https://dallas-cowboys-roster-89666b416610.herokuapp.com/`

export const getPlayers = async () => {
  try {
    const response = await axios(`${apiUrl}/players`)
    const players = response.data
    return players
  } catch (error) {
    throw error
  }
}

export const getPlayer = async id => {
  try {
    const response = await axios(`${apiUrl}/players/${id}`)
    const player = response.data
    return player
  } catch (error) {
    throw error
  }
}

export const createPlayer = async player => {
  try {
    const response = await axios.post(`${apiUrl}/players`, player)
    return response.data
  } catch (error) {
    throw error
  }
}

export const updatePlayer = async (id, player) => {
  try {
    const response = await axios.put(`${apiUrl}/players/${id}`, player)
    return response.data
  } catch (error) {
    throw error
  }
}

export const deletePlayer = async id => {
  try {
    const response = await axios.delete(`${apiUrl}/players/${id}`)
    return response.data
  } catch (error) {
    throw error
  }
}

About

The Dallas Cowboys Roster Editor is a full CRUD React app to update the Dallas Cowboy Roster API I created for the Dallas Cowboys Calculator that I also created.

Topics

Resources

Stars

Watchers

Forks