Open edwinjosechittilappilly opened 1 month ago
Thank you for considering this enhancement to the JavaScript API modal snippet. I believe updating it to use fetch instead of a client library will provide a clearer, more intuitive example for developers. Here’s a suggested approach:
fetch("https://api.langflow.astra.datastax.com/lf/7436dcd2-a480-4009-bce2-43ba959692e5/api/v1/run/5a232ac1-df88-478e-ad90-be6a98ae08a2?stream=false", { method: "POST", headers: { Authorization: "Bearer <TOKEN>", "Content-Type": "application/json" }, body: JSON.stringify({ key: "value" }) // Replace with actual request data }) .then(response => { if (!response.ok) throw new Error('Network response was not ok'); return response.json(); }) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
This snippet improves readability, especially for developers familiar with the fetch API, by making API requests straightforward and comparable to the existing curl snippet.
Additionally, I see potential for similar improvements to the Python API snippet, which could better reflect real-world usage by avoiding an illustrative main and focusing instead on practical, server-oriented examples. Here’s a possible revision: `import requests
url = "https://api.langflow.astra.datastax.com/lf/7436dcd2-a480-4009-bce2-43ba959692e5/api/v1/run/5a232ac1-df88-478e-ad90-be6a98ae08a2"
headers = {
"Authorization": "Bearer
response = requests.post(url, headers=headers, json=data) print(response.json() if response.ok else f"Error: {response.status_code}") ` Additionally, creating an npm package that simplifies API interactions with both streaming and non-streaming options would streamline the process for JavaScript developers, providing a more cohesive experience when handling Langflow API requests.
Thank you for the opportunity to contribute. Please let me know if there’s any additional feedback or specific guidelines for these updates!
Feature Request
The current JavaScript code snippet in the API modal is not an ideal example of how our developers would typically write or use JavaScript, especially when compared to the curl snippet. A more equivalent and intuitive snippet would fetch data from the network using fetch rather than employing a client.
Suggested Solution:
Please update the JavaScript code snippet in the modal to align more closely with the curl snippet. A suggested code would look something like this:
Motivation
Additional Feedback:
cc: @philnash @mieslep
Your Contribution
No response