-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RMET-2252 :: Remove JSON file dependency , add Endpoint (#38)
* feat: add endpoint logic to android hook * fix: add config parser import * removing fetch + add axios * minor typo fix * feat: add get endpoint to iOS * remove static dependency * adding more error handling * chore: refactor * refactor: rename preference to be more accurate * reactor: change preference according to Dev Exp suggestion * fix: change error accordingly
- Loading branch information
1 parent
c6857fa
commit 9643606
Showing
4 changed files
with
100 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const axios = require('axios'); | ||
|
||
module.exports = { | ||
getJsonFile: async function getJsonFile(endpoint, appName){ | ||
try { | ||
let response = await axios.get(endpoint, { | ||
params: { AppName : appName } | ||
}); | ||
|
||
let json = response.data; | ||
return json; | ||
} catch(err){ | ||
if(err.response){ | ||
if(err.response.status == 400){ | ||
let data = err.response.data; | ||
if(data.Errors){ | ||
throw new Error(data.Errors); | ||
} else throw new Error("Bad Request: make sure your apps is configured correctly") | ||
} | ||
if(err.response.status == 404){ | ||
throw new Error("Not found: Social Logins Configurator is either outdated or CONFIGURATOR_BASE_URL is not well defined."); | ||
} | ||
} else if(err.request){ | ||
throw new Error("Something went wrong with the request. " + err.toJSON()); | ||
} else{ | ||
throw new Error(err.message) | ||
} | ||
} | ||
}, | ||
ProvidersEnum: Object.freeze({"apple":"1", "facebook":"2", "google":"3", "linkedIn":"4"}), | ||
ApplicationTypeEnum: Object.freeze({"web":"1", "ios":"2", "android":"3"}) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,8 @@ | |
"browser" | ||
] | ||
}, | ||
"engines": [] | ||
"engines": [], | ||
"dependencies": { | ||
"axios": "^1.3.3" | ||
} | ||
} |