Is it possible to parse outside API in Elixir in a similar way below? Or do I use Path Helper; user_path(Endpoint, :show, 17, admin: true, active: false)
?
router.get('/', function(req, res, next) {
const url = "https://newsapi.org/v2/top-headlines?pageSize=20&category=business&apiKey=920204";
request.get(url, (err, response, body) => {
if(err) { console.error(err) }
body = JSON.parse(body);
const imgUrl = body.articles[1].urlToImage
res.render('index', { title: 'The News', imgUrl: imgUrl});
});
});
I think this might work. https://stackoverflow.com/questions/46633620/make-http-request-with-elixir-and-phoenix