Git Product home page Git Product logo

Comments (3)

strid3r21 avatar strid3r21 commented on June 3, 2024 1

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
jsonGenius-web

from jsongenius.

semanser avatar semanser commented on June 3, 2024

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.

semanser avatar semanser commented on June 3, 2024

Nice, glad to see you solved it!

from jsongenius.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.