Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const router = express.Router();
- const axios = require('axios');
- /* GET home page. */
- router.get('/', (req, res, next)=> {
- let instaPost;
- getLatest(callback => {
- instaPost = callback;
- console.log(instaPost);
- });
- res.render('index', {
- title: 'Home',
- insta: instaPost
- });
- });
- function getLatest(callback) {
- axios.get('https://api.instagram.com/v1/users/self/media/recent/?access_token=xxx&count=1')
- .then(response => {
- callback((response.data.data[0].link));
- })
- .catch(error => {
- callback(error);
- });
- }
- module.exports = router;
Add Comment
Please, Sign In to add comment