Can I call an external API from within Kintone?

3 followers Follow
Avatar
Nathan Waterman

I've been trying to make a call to an external service as part of a test but I get nothing back, not even an error. Is this possible?

0

4 comments

Avatar
Nathan Waterman 0 votes
(function() {

const apiKey = "api key removed";
const feed = `https://newsapi.org/v2/everything?q=texas&apiKey=${apiKey}`;

let changeName = "txtName";

const news = () => {
return fetch(feed)
.then((resp) => {
if (resp.status === 200) {
return resp;
}
}).then(data => {
let topStory = data.json();
return topStory;
}).catch((err) => {
console.log(err);
});
};

var events = ["app.record.create.change." + changeName, 'app.record.edit.change.' + changeName];
let record;

news().then((data) => {
kintone.events.on(events, function(event) {
record = event.record;
console.log(record);
record[changeName].value = data.articles[0].title;
});
});

}());
0
Avatar
Junko Werner 0 votes
There are several ways to run an external API, and Kintone provides an API that allows you to run external APIs.
 
 
As for the details of the parameter, it depends on the API you are trying to run, so I am not sure exactly what you need in your case but hopefully kintone.proxy run the desired API you are working on.
0

Please sign in to leave a comment.