Fixed: IHttpClient in 2 beta 11

Hi, did something change recently regarding the Fetch Client ?

I am trying to get the IHttpClient setup in a service class, using the example in the documentation. Like this:

    constructor(@newInstanceOf(IHttpClient) readonly http: IHttpClient) {
        http.configure(config =>
        config
            .withBaseUrl('/api/')
            .withDefaults({
                credentials: 'same-origin',
                headers: {
                    'Accept': 'application/json',
                    'X-Requested-With': 'Fetch'
                }
            })
            .withInterceptor({
                async response(response) {
                    if(response.ok && response.headers.get('Content-Type').startsWith('application/json')) {
                        const data = await response.json();
                        return data
                    }
                    return response;
                }
            }
        ));
    }

The browser console is giving me the following error:

Error: AUR0017: Failed to instantiate ‘InterfaceSymbol’ via @newInstanceOf/@newInstanceForScope, there’s no registration and no default implementation.

These are my imports:

import {IHttpClient} from '@aurelia/fetch-client';
import { newInstanceOf } from '@aurelia/kernel';
1 Like

I don’t know the details, but there was a recent fix regarding IHttpClient injection:

Ahh, looks like something happened.
I tried beta 10 and it works as documented. Maybe I’ll hang tight until beta 12.
Thanks!

beta 12 fixed this. Thanks!

1 Like