Skip to content

Instantly share code, notes, and snippets.

@ryanjohnston
Last active September 9, 2018 18:36
Show Gist options
  • Save ryanjohnston/9faffbf72b9759b6cd60a5c09f7ef4f2 to your computer and use it in GitHub Desktop.
Save ryanjohnston/9faffbf72b9759b6cd60a5c09f7ef4f2 to your computer and use it in GitHub Desktop.
[Moovweb - Snippets] Snippets, Gists and Workflows
import fetch from 'fetch'
import { withGlobalState } from 'moov-pwa/router'
import globalState from '../globalState'
export default async function menuHandler() {
// Need to learn about config api
// const { hostname, port, apiKey } = Config.get('upstreamApi')
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
const hostname = "174.143.190.67"
// Manually passing headers object within fetch command below.
// Do not need the following code (which was doing same thing).
//
// let headers = new Headers();
// headers.append('authorization', "Basic cmVzdDpyZXN0")
// headers.append('cache-control', "no-cache")
const productInfo = await fetch(`https://${hostname}:443/pwa/cms/menu`, {
method: "GET",
headers: {
'Authorization': 'Basic cmVzdDpyZXN0',
'cache-control': 'no-cache'
}
}).then(res => {
console.log(res);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment