Skip to content

Commit

Permalink
This commit added async await in functions for fetching api in App.js…
Browse files Browse the repository at this point in the history
… file
  • Loading branch information
ayesha-ghani098 committed Aug 23, 2021
1 parent 6f800f3 commit 7dcb1a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Binary file added Untitled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const App = () => {
}, []);

// Move books on different shelf function
const updateShelf = (book, shelf) => {
console.log('Move to =>', book, shelf);
BooksApi.update(book, shelf).catch((err) => {
const updateShelf = async (book, shelf) => {
// console.log('Move to =>', book, shelf);
await BooksApi.update(book, shelf).catch((err) => {
console.log(err);
});
if (shelf === 'none') {
Expand All @@ -42,9 +42,9 @@ const App = () => {
};

// Search books function
const searchBooks = debounce(200, false, (query) => {
const searchBooks = debounce(200, false, async (query) => {
if (query.length > 0) {
BooksApi.search(query).then((book) => {
await BooksApi.search(query).then((book) => {
if (book.error) {
setSearchBooks([]);
} else {
Expand Down

0 comments on commit 7dcb1a9

Please sign in to comment.