fetchAll Database query returns an error
fetchAssoc worked for you because of the result is an associative array.
fetchAll did not work because the result is an array of stdClass objects and JSON normalizer did not know how to return the data.
I think you will need fetchAllKeyed(0,0), but better play around a bit.
reference: https://www.drupal.org/docs/8/api/database-api/result-sets