Created
December 14, 2017 13:04
-
-
Save danilvalov/cde1680ce3eabaeb41361d27db7286b5 to your computer and use it in GitHub Desktop.
Get instagram media array by tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('async-request'); | |
module.exports = async (tag) => { | |
try { | |
const response = await request(`https://www.instagram.com/explore/tags/${encodeURIComponent(tag)}/?__a=1`); | |
if (response.statusCode != 200) { | |
return throw response.statusCode; | |
} | |
try { | |
const jsonResponse = JSON.parse(body); | |
return jsonResponse.tag.media.nodes; | |
} catch (error) { | |
return throw error; | |
} | |
} catch (error) { | |
return throw error; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment