beyonk-group / http

An isomorphic http client for Svelte applications
45 stars 4 forks source link

Api client must be configured #12

Closed vdelacerda closed 3 years ago

vdelacerda commented 3 years ago

Hello, I am following your setup example but getting this error :+1: Api client must be configured

In my client.js :

import * as sapper from '@sapper/app'
import Api from '@beyonk/sapper-httpclient'

Api.configure({ baseUrl: 'http://localhost:8080' })
sapper.start({
    target: document.querySelector('#sapper')
});

In my server.js :

...
import Api from '@beyonk/sapper-httpclient'

Api.configure({ baseUrl: 'http://localhost:8080' })

const { PORT, NODE_ENV } = process.env
const dev = NODE_ENV === 'development'
...

And I use :

import httpClient from '@beyonk/sapper-httpclient'

const api = httpClient.create();

Thanks for your help, your package could be exactly what I need

antony commented 3 years ago

That looks fine to me - I'm not sure why you'd get this error?

you're using it essentially the way we use it.

However I do notice that your import * as sapper/app wouldn't work - it's @sapper/server you need there. So I wonder if the code you've written here isn't exactly as it is in your application.

If you can reproduce with a blank Sapper template I could look into it.

vdelacerda commented 3 years ago

I created my project from the sapper-template : https://github.com/sveltejs/sapper-template And in the src/client.js :

import * as sapper from '@sapper/app';

sapper.start({
    target: document.querySelector('#sapper')
});

But I will try from a blank project.

vdelacerda commented 3 years ago

It works from the Sapper Template... Maybe a conflict with my packages