Request from one docker container to another fails

I’ve been trying to connect two docker containers. My flask backend and my react frontend, when I use localhost in the request the request goes through, but when i use the docker container name ie http://backend-service:5000/endpoint , the name can’t be resolved. The documentation states that the containers connect to the same networking automatically and that accessing services from one should be as simple as that. I’ve tried adding links to the docker compose file as well with no luck.

Here is my docker-compose file:

version: '3'

services:
  backend-service:
    build: ./api
    expose:
      - 5000
    ports:
      - "5000:5000"
    volumes:
      - ./api:/usr/src/app
    environment:
      - FLASK_ENV=development
      - FLASK_APP=app.py
      - FLASK_DEBUG=1
  client-service:
    build: ./clientside
    expose: 
      - 3000
    ports:
      - "3000:3000"
    volumes:
      - ./clientside/src:/usr/src/app/src
      - ./clientside/public:/usr/src/app/public
    links:
      - "backend-service:backend"

Source: StackOverflow