How can I configure the heroku env in javascript in rails for an instagram api this is just my code
var token = <%= ENV['MY_API_TOKEN'] %>,
userid = <%= ENV['MY_API_USERID'] %>,
num_photos = 10;
$(document).ready(function() {
$.ajax({
url: 'https://api.instagram.com/v1/users/' + userid + '/media/recent/?access_token=' + token,
dataType: 'jsonp',
type: 'GET',
data: {access_token: token, count: num_photos},
success: function(data){
console.log(data);
for( x in data.data ){
$("#container").append('<li><img src="'+data.data[x].images.standard_resolution.url+'"></li>');
}
},
error: function(data){
console.log(data);
}
});
});
The only thing that echo is to change js by js.erb and already put the key in env of heroku
go to to your app page on heroku then
Settings -> in Config Variables section click on Reveal Config Vars and then just insert your key
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.