Skip to content

Instantly share code, notes, and snippets.

@dmi3coder
Last active May 31, 2020 13:50
Show Gist options
  • Save dmi3coder/3629d3dea74654217ab47eca8afea23d to your computer and use it in GitHub Desktop.
Save dmi3coder/3629d3dea74654217ab47eca8afea23d to your computer and use it in GitHub Desktop.
Example of networking class for React and Quarkus communication with Swagger
import SwaggerClient from "swagger-client";
export default class Networking {
static client = new SwaggerClient({
url: 'http://localhost:8080/openapi'
});
// TODO security
static exec = ({endpoint, attributes, data, success, failure = res => console.log('failed on api call: ' + res)}) => {
this.client.then(
client => endpoint(client)(attributes, data),
reason => {
failure(reason);
console.error('failed to load the spec: ' + reason)
}
).then(success, failure);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment