Skip to content

Write backend code to send data to frontend #55

@AbraamIbrahim

Description

@AbraamIbrahim

Goal: Write reusable service functions to use in React anywhere we need to fetch from Flask or connect via SocketIO

File 1: HTTP API Service (src/services/api.js)

  • Create file with base URL configuration (http://localhost:5500)
  • Write async functions for all Flask endpoints
  • Use fetch() to make HTTP requests
  • Return JSON responses

File 2: WebSocket Service (src/services/socket.js)

  • Install socket.io-client: npm install socket.io-client
  • Create SocketService class with connect/disconnect methods
  • Set up connection to http://localhost:5500
  • Add on() method to listen for real-time events from Flask
  • Add emit() method to send events to Flask
  • Export singleton instance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions