Hello,
I’d like to get the HTML content of a website (server side to prevent CORS policy problem) when the address is typed on an input, and give it to the template (I plan to parse the <title></title>
but no help needed for this).
I tried many different ways but I’m getting confused. I’m looking for a hint
Here is my current code:
imports/ui/input.html:
<template name="input">
<input type="text" name="link" placeholder="http(s)://..." />
<input type="text" name="description" placeholder="description" value="{{curl}}" />
</template>
imports/ui/input.js:
Template.input.helpers({
curl() {
return Session.get('curl');
}
});
Template.input.events({
'keyup [name="link"]'(event){
Meteor.call('input.curl', event.target.value, function(error, result){
if(error)
uiCallback(error)
else{
console.log(result);
Session.set('curl', result);
}
});
}
});
imports/api/categories.js:
if (Meteor.isServer) {
Meteor.methods({
'input.curl'(link){
let ret = HTTP.post(link, (error, result) => {
console.log(result.content);
return result;
});
return ret;
}
});
}
Thank you