I want to know how to connect API to oxide in journeyApps and can we use other than node.js in cloud code
Hi @Soumya
CloudCode is node.js only for now. If you would like support for other development / coding languages you can submit a feature / idea on our public roadmap - here
As for your first question, I need a bit more information to be able to assist. What API do you want to connect to? And when you say connect the API in OXIDE, do you mean how do you access an external API (like an API on an existing system) from your App? Or are you referring to the JourneyApps Backend API that get’s created for you by default for each of your apps?
If the latter, the API details can be accessed from the Backend that you want to integrate with, not from OXIDE directly (at least not yet). More information on the backend API is available here
I hope this helps
I need to call the API to get the data and dispaly the device information in UI (API contains the information when I click on the number it should display a device/product information) so for that how can I do in journeyApps
If you want to make an API call from within your app you can make a FETCH api call directly from the View JS. Docs here
However, if you are interested in accessing information about the device then you may find what you are looking for in the journey
object that is accessible directly in the View JS. Docs here
Is this what you are looking for?
I have taken a code from [[docs.journeyapps.com]]
and the code goes like this:
var url = ‘https://sandbox.gateway.emerson.com/api/aslgrp/data-service/v1/serialNumber’;
function runapi()
{
return fetch(url, {})
.then(function(response) {
// Parse JSON from the body
return response.json()
})
.then(function(jsonData) {
dialog('Results for entered serial number', jsonData.results)
});
}
When I entered the serial number in input box and got the result as entered serial number dialog box
So I need the details of entered serial number
So for that how to call the API ? If my code went wrong please correct me
Have you been able to get the API call to work using something like Postman or Insomnia? If not, I would definitely try that first to make sure you understand how the API works, what the expected request URL and Body needs to be, and what the expected response will be.
My gut feeling is that you need to pass the entered serial number to the API, either by adding a URL parameter or by adding the serial number in the request body, depending on how that specific API works. If your app you have used a view variable to store the serial number then you can access that from the JS by referencing it using the view.varName
syntax.
So something like this may work, but again, that depends on how that specific API works
var url = ‘https://sandbox.gateway.emerson.com/api/aslgrp/data-service/v1/serialNumber’;
function runapi() {
url = url + "?" + view.serial_number
return fetch(url, {})
.then(function(response) {
// Parse JSON from the body
return response.json()
})
.then(function(jsonData) {
dialog('Results for entered serial number', jsonData.results)
});
}
Hope this gets you on the right track. If not, can you please elaborate on where you are currently experiencing problems and also confirm that you can get the API call to work outside the App first using a Rest client (or similar)
Thanks for the information