Last active
May 31, 2020 13:50
-
-
Save dmi3coder/3629d3dea74654217ab47eca8afea23d to your computer and use it in GitHub Desktop.
Example of networking class for React and Quarkus communication with Swagger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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