Spring Boot + React application: list from GET request not appearing on webpage

I’m a beginner and have been trying to learn web development by creating a basic full stack banking web application with spring boot for backend and react for the frontend. Its been going decently, however im stuck at this part where upon logging in with an authenticated user, it is supposed to direct you to a page with the header “Accounts List” and a bulleted list of the user’s accounts. When I log in, it brings me to this page, except all it displays is the header, without the list of accounts. I don’t get any error messages upon logging in, and I’ve also tested the GET request endpoint for fetching the list of a user’s accounts in postman, and it works fine on there. Does anyone have any advice for what might be causing this? Here is my .js file for the Account List Page:

import React, { useEffect, useState } from 'react';
import axios from 'axios';

const AccountListPage = ({ username }) => {
    const [accounts, setAccounts] = useState([]);
    const [error, setError] = useState(null);

    const fetchAccounts = async (username) => {
        try {
            const response = await axios.get(`http://localhost:8080/api/accounts?username=${username}`);
            setAccounts(response.data); // Assuming response.data is an array of accounts
        } catch (error) {
            console.error('Error fetching accounts', error);
            setError('error fetching accounts');
        }
    };

    useEffect(() => {
        if (username) {
            fetchAccounts(username);
        }
    }, [username]);

    return (
        <div>
            <h2>Account List</h2>
            {error && <p>{error}</p>}
            <ul>
                {accounts.map(account => (
                    <li key={account.id}>
                        {account.accountType} - {account.balance}
                    </li>
                ))}
            </ul>
        </div>
    );
};

export default AccountListPage;

And here is my Account Controller class in my spring boot application:

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.example.banking3.User.CustomUserDetailsService;

@Controller
@RequestMapping("/api/accounts")
public class AccountController {
    
    @Autowired
    private AccountService accountService;

    @Autowired
    private CustomUserDetailsService customUserDetailsService;

    @GetMapping
    public ResponseEntity<?> getAccounts(@RequestParam String username) {
        try {
            List<Account> accounts = accountService.findAccountsByUsername(username);
            return ResponseEntity.ok(accounts);
        } catch (Exception e) {
            return ResponseEntity.status(500).body("Error retrieving accounts");
        }
    }

    @PostMapping("/{userId}")
    @ResponseBody
    public ResponseEntity<Account> addAccountToUser(
        @PathVariable Long userId,
        @RequestBody Account account){
        Account savedAccount = accountService.addAccountToUser(userId, account);
        return ResponseEntity.ok(savedAccount);
    }

    @PutMapping("/{accountId}/deposit")
    @ResponseBody
    public ResponseEntity<Account> deposit(
        @PathVariable Long accountId,
        @RequestBody Double amount){
        Account updatedAccount = accountService.deposit(accountId, amount);
        return ResponseEntity.ok(updatedAccount);
    }

    @PutMapping("/{accountId}/withdraw")
    @ResponseBody
    public ResponseEntity<Account> withdraw(
        @PathVariable Long accountId,
        @RequestBody Double amount) {
        Account updatedAccount = accountService.withdraw(accountId, amount);
        return ResponseEntity.ok(updatedAccount);
    }
}

Have tried youtube, online forums, and chatgpt.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật