Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-co committed Jun 4, 2024
1 parent b266a4c commit 336b76c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
33 changes: 13 additions & 20 deletions React/test-feedback/db.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
{
"Feed": [
{
"id": 1,
"id": "1",
"rating": 10,
"text": "Lorem ipsum dolor sit amet consectetur adipisicing elit. consequuntur vel vitae commodi alias voluptatem est voluptatum ipsa quae.",
"createdDtm": "5/30/2024, 09:51:28",
"updatedDtm": ""
"createDtm": "5/30/2024, 09:51:28",
"updateDtm": ""
},
{
"id": 2,
"id": "2",
"rating": 9,
"text": "Lorem ipsum dolor sit amet consectetur adipisicing elit. consequuntur vel vitae commodi alias voluptatem est voluptatum ipsa quae.",
"createdDtm": "5/30/2024, 09:51:29",
"updatedDtm": ""
"createDtm": "5/30/2024, 09:51:29",
"updateDtm": ""
},
{
"id": 3,
"id": "3",
"rating": 8,
"text": "Lorem ipsum dolor sit amet consectetur adipisicing elit. consequuntur vel vitae commodi alias voluptatem est voluptatum ipsa quae.",
"createdDtm": "5/30/2024, 09:51:30",
"updatedDtm": ""
"createDtm": "5/30/2024, 09:51:30",
"updateDtm": ""
},
{
"id": "299f90b8-edea-460a-8eeb-d710af107a10",
"text": "testonetwothree",
"rating": "7",
"createdDtm": "5/30/2024, 09:51:31",
"updatedDtm": ""
},
{
"id": "ccbd64d8-3ccb-4a71-88cb-eb0b281ca35d",
"text": "aafafafafaee",
"rating": "4",
"createDtm": "5/30/2024, 09:53:01"
"id": "08216a30-09dc-4f9c-8d3a-9c949254467c",
"text": "ddddddddddddddddddd",
"rating": "2",
"createDtm": "6/4/2024, 09:52:13"
}
]
}
7 changes: 4 additions & 3 deletions React/test-feedback/src/context/FeedContext.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { createContext, useEffect, useState } from 'react'
import Feedback from '../data/FeedData'

const URL = 'http://localhost:2040/Feed'
const URL = 'http://localhost:2040/Feed/'

const FeedContext = createContext()

Expand All @@ -19,15 +19,16 @@ export const FeedProvider = ({ children }) => {
}, [])

const getFeeds = async () => {
const res = await fetch(URL + '?_sort=id')
const res = await fetch(URL + '?_sort=createDtm&_order=desc')
const data = await res.json()
console.log(data)
setFeed(data)
}

const deleteFeed = async (id) => {
setFeed(feed.filter(f => f.id !== id))
await fetch(URL + id, {
method: 'delete'
method: 'DELETE'
})
}

Expand Down

0 comments on commit 336b76c

Please sign in to comment.