generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Handle the Worker event. Fetches school details for the provided lat/long. | ||
* | ||
* @param {Object} event the worker event. | ||
* @param {string} event.data.api the URL to fetch. | ||
* @param {string} event.data.id - The ID of the listing. | ||
* @param {string} event.data.lat latitude | ||
* @param {string} event.data.long longitude | ||
* @param {string} event.data.zipcode the zip code | ||
*/ | ||
onmessage = async (event) => { | ||
const { | ||
id, lat, long, zip, | ||
} = event.data; | ||
const promises = []; | ||
promises.push( | ||
fetch(`/bin/bhhs/pdp/cregSchoolServlet?PropertyId=${id}&Latitude=${lat}&Longitude=${long}&zipCode=${zip}`) | ||
.then((resp) => (resp.ok ? resp.json() : undefined)), | ||
); | ||
|
||
Promise.all(promises).then((values) => { | ||
postMessage(values.filter((v) => v)); | ||
}); | ||
}; |
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,20 @@ | ||
/** | ||
* Handle the Worker event. Fetches school details for the provided lat/long. | ||
* | ||
* @param {Object} event the worker event. | ||
* @param {string} event.data.api the URL to fetch. | ||
* @param {string} event.data.lat latitude | ||
* @param {string} event.data.long longitude | ||
*/ | ||
onmessage = async (event) => { | ||
const { lat, long } = event.data; | ||
const promises = []; | ||
promises.push( | ||
fetch(`/bin/bhhs/pdp/cregSchoolServlet?latitude=${lat}&longitude=${long}`) | ||
.then((resp) => (resp.ok ? resp.json() : undefined)), | ||
); | ||
|
||
Promise.all(promises).then((values) => { | ||
postMessage(values.filter((v) => v)); | ||
}); | ||
}; |