Comments (3)
so i laterally just figured it out. it was a CORs issue that was blocking the return response.
since im testing this locally my web page is at localhost:3000 and jsonGenius is on 3001
i just needed to start a CORs proxy and use that as an in-between.
so for others that may run into this, this is what i did.
#1 in new terminal install this CORs proxy server
npm install -g local-cors-proxy
then start the proxy server for JsonGenius like so
lcp --proxyUrl http://localhost:3001
this will start the proxy server. leave it running while you work.
then in javascript code use that proxy like so.
const jsonPackage = JSON.stringify({
"url": "https://www.amazon.com/s?k=gaming+headsets",
"schema": {
"type": "object",
"properties": {
"products": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The product name"
},
"price": {
"type": "number",
"description": "The price of the product in USD"
}
}
}
}
}
}
})
const sendURLtoJsonGenius = async () => {
try{
const response = await fetch('http://localhost:8010/proxy/lookup', { <---------------
method: 'POST',
mode: 'cors',
headers: { "Content-Type": "application/json" },
body: jsonPackage ,
});
const data = await response.json() <---the results come in here
console.log("Success:",data)
}catch(error) {
console.log("error:", error)
}
}
which returns the results in the webpage like so
from jsongenius.
Hi,
There are no pre-built executables for jsongenius (yet), but you could try to compile it on your own if you would like. It should be as simple as running go build . (assuming that you have the Go language toolchain installed).
Also, you should be able to "poll the response data and use it outside of Docker" right now. In your example above, you're making a request to the Docker container, and you should be able to get the response back. Can you provide your console.log("error:", error) output?
from jsongenius.
Nice, glad to see you solved it!
from jsongenius.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsongenius.