Copy link to clipboard
Copied
I currently have a jQuery ajax call to a third-party API, which checks a vehicle's licence plate against a national database:
$.ajax({
type: "get",
url: "https://test.carjam.co.nz/a/vehicle:abcd",
data: {key:key,plate:plate},
dataType: "json",
success: function(res){
// display message validating license plate and save response data into database
}
// other code
});
However, the third party now requires the call to be from the "back end", as any attempts to use browser code such as JS or juery will result in a "cross-origin" related error.
What would be the most effective way to bring this into the back-end? Via a cfc?
They also give the option of using node.js, which I know nothing about.
This should be pretty easy with CFHTTP whether you use a CFC for it or not. This is kind of an old-school response, but it should get you started:
https://stackoverflow.com/questions/58090695/trying-to-convert-json-http-post-to-cfhttp-post
Copy link to clipboard
Copied
This should be pretty easy with CFHTTP whether you use a CFC for it or not. This is kind of an old-school response, but it should get you started:
https://stackoverflow.com/questions/58090695/trying-to-convert-json-http-post-to-cfhttp-post
Copy link to clipboard
Copied
I would also suggest cfhttp:
licencePlateCheck.cfm
<cfhttp method="get" url="https://test.carjam.co.nz/a/vehicle:abcd" >
<cfhttpparam type="url" name="key" value="myKey" >
<cfhttpparam type="url" name="plate" value="myPlate" >
</cfhttp>
<cfdump var="#cfhttp.filecontent#" >
Find more inspiration, events, and resources on the new Adobe Community
Explore Now