need help creating a delete feed create a new async function called deleteFeedApi which takes in the following parameters: token, feedId. In your src/util/ApiUtil.js file, add code to use Axios and call the delete feed request api in deleteFeedApi function: The code should make a DELETE request to the API endpoint ${API_BASE_URL}/feeds/${feedId} . For The Authorization header, set the value of frameToken(token) where token is the token parameter passed to the function. If the request is successful and the status code is 200, update the response and indicate success using frameResponse(1). If there is an error, execute the catch block. If there is a response available in the error object, update the response with the error message. If there is no response available, the error should be logged to the console. Finally, return the response to the function.   In src/pages/App/MyFeeds.js, pass a prop loadOnDelete={getMyFeeds} in FeedCard component under your MyFeeds component. In src/components/App/FeedCard.js, import your deleteFeedApi from src/util/ApiUtil.js. In src/components/App/FeedCard.js, add a new prop loadOnDelete = undefined in your FeedCard component. In src/components/App/FeedCard.js, create a new function called deleteFeed: Check if isFetching is false. Set isFetching to true. The code should make a call to the deleteApi function with the token and feedId as parameters. If the API call returns a status of 1, Call loadOnDelete(0) to update the component in MyFeeds and reload the feeds. Set isFetching to false.   {loadOnDelete && ( )}

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help creating a delete feed

  1. create a new async function called deleteFeedApi which takes in the following parameters: token, feedId.

  2. In your src/util/ApiUtil.js file, add code to use Axios and call the delete feed request api in deleteFeedApi function:

    • The code should make a DELETE request to the API endpoint ${API_BASE_URL}/feeds/${feedId} .

    • For The Authorization header, set the value of frameToken(token) where token is the token parameter passed to the function.

    • If the request is successful and the status code is 200, update the response and indicate success using frameResponse(1).

    • If there is an error, execute the catch block. If there is a response available in the error object, update the response with the error message. If there is no response available, the error should be logged to the console.

    • Finally, return the response to the function.

       

  3. In src/pages/App/MyFeeds.js, pass a prop loadOnDelete={getMyFeeds} in FeedCard component under your MyFeeds component.

  4. In src/components/App/FeedCard.js, import your deleteFeedApi from src/util/ApiUtil.js.

  5. In src/components/App/FeedCard.js, add a new prop loadOnDelete = undefined in your FeedCard component.

  6. In src/components/App/FeedCard.js, create a new function called deleteFeed:

    • Check if isFetching is false.

    • Set isFetching to true.

    • The code should make a call to the deleteApi function with the token and feedId as parameters.

    • If the API call returns a status of 1, Call loadOnDelete(0) to update the component in MyFeeds and reload the feeds.

    • Set isFetching to false.

       

  7. {loadOnDelete && ( <div className="flex flex-col justify-center m-5" onClick={deleteFeed} > <span className="transition ease-out duration-300 hover:bg-gray-50 bg-gray-100 h-8 px-2 py-2 text-center rounded-full text-gray-100 cursor-pointer"> <svg className="h-4 w-4 text-gray-500" fill="none" viewBox="0 0 24 24" > <path fill="currentColor" d="M7 21q-.825 0-1.413-.588T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.588 1.413T17 21H7ZM17 6H7v13h10V6ZM9 17h2V8H9v9Zm4 0h2V8h-2v9ZM7 6v13V6Z" /> </svg> </span> </div> )}
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education