beyonk-group / http Goto Github PK
View Code? Open in Web Editor NEWAn isomorphic http client for Svelte applications
An isomorphic http client for Svelte applications
when doing import { configure } from "@beyonk/sapper-httpclient" in server.js, the configure module is imported but while doing the same in client.js, it shows Non-existent export 'configure' is imported from node_modules/@beyonk/sapper-httpclient/index.js
Hi, is there a way to use this package with responses of type "blob" from the endpoint instead of json ?
I am following your setup example but getting this error
using Svelte 3.0.0, Sapper 0.27.4
'configure' is not exported by node_modules/@beyonk/sapper-httpclient/index.js
I have this on sapper preload section and get this that error
<script context="module">
import {create} from '@beyonk/sapper-httpclient';
export function preload(page) {
const api = create();
return {json} = await api
.transport(fetch) // pass node fetch in here.
.endpoint('/meetups')
.get();
console.log(json);
}
</script>
using Svelte 3.0.0, Sapper 0.27.4
On server load data loads correctly but once single page kicks in and going back to the page throws this error
Access to fetch at 'http://localhost:3001/api/v1/meetups' from origin 'http://localhost:3000' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'.
In your Isomorphic example, I am unable to import fetch from @sapper/app
I am running Svelte 3.24
<script context="module">
import { create } from "@beyonk/sapper-httpclient";
import { fetch } from "@sapper/app";
export async function preload(page, session) {
const api = create();
const res = await api
.transport(fetch) // Use sapper's built in "fetch" method
.endpoint("http://scrapex.local/api/")
.get();
}
</script>
Also, how can I add 'credentials': 'include' with this isomorphic fetch call?
Hello, I am following your setup example but getting this error ๐
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.