Skip to content

Commit

Permalink
fix(:bug:): improve error message when no FormData or Promise can be …
Browse files Browse the repository at this point in the history
…found

AFFECTS PACKAGES:
@esri/arcgis-rest-request

ISSUES CLOSED: #322
  • Loading branch information
jgravois committed Sep 17, 2018
1 parent b93bd55 commit 89ff196
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/arcgis-rest-request/src/request.ts
Expand Up @@ -169,17 +169,21 @@ export function request(
recommendedPackages.push("`isomorphic-fetch`");
}

if (!Promise) {
if (typeof Promise === "undefined") {
missingGlobals.push("`Promise`");
recommendedPackages.push("`es6-promise`");
}

if (!FormData) {
if (typeof FormData === "undefined") {
missingGlobals.push("`FormData`");
recommendedPackages.push("`isomorphic-form-data`");
}

if (!options.fetch || !Promise || !FormData) {
if (
!options.fetch ||
typeof Promise === "undefined" ||
typeof FormData === "undefined"
) {
throw new Error(
`\`arcgis-rest-request\` requires global variables for \`fetch\`, \`Promise\` and \`FormData\` to be present in the global scope. You are missing ${missingGlobals.join(
", "
Expand Down

0 comments on commit 89ff196

Please sign in to comment.