Created
January 11, 2017 19:34
-
-
Save mikker/1bef412a2072480743facd532fa92b2e to your computer and use it in GitHub Desktop.
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
/* globals fetch */ | |
require('isomorphic-fetch') | |
const { parse } = require('url') | |
const { send } = require('micro') | |
module.exports = async (req, res) => { | |
const { query } = parse(req.url) | |
res.setHeader('Access-Control-Allow-Origin', '*') | |
res.setHeader('Content-Type', 'application/json') | |
searchItunes(query) | |
.then(data => { send(res, 200, data) }) | |
.catch(error => { send(res, 500, error) }) | |
} | |
const searchItunes = (query) => | |
fetch(`https://itunes.apple.com/search?${query}`).then(resp => resp.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment