mcdonald-location-apiv2
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "mcdonald-location-apiv2", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A Node.js library to programmatically find the nearest McDonald's locations and perform searches on the McDonald's site.", | ||
@@ -28,5 +28,4 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"express": "^4.17.1", | ||
"axios": "^0.21.1" | ||
} | ||
} |
@@ -60,1 +60,28 @@ # mcdonald-location-apiv2 | ||
## Feature: Search McDonald's Site | ||
This library includes a function, `searchMcDonaldsSite`, that allows you to search the McDonald's website for specific content. You can specify a search query and an optional limit for the number of results returned. | ||
### Function: `searchMcDonaldsSite(searchText, resultLimit)` | ||
#### Parameters: | ||
- `searchText` (**String**): The text string you want to search for on the McDonald's site. | ||
- `resultLimit` (**Number**, *optional*): The maximum number of search results to return. Defaults to 10 if not specified. | ||
#### Returns: | ||
- A promise that resolves to an array containing the titles of search results. The size of the array is determined by `resultLimit`. | ||
#### Usage Example: | ||
```javascript | ||
const { searchMcDonaldsSite } = require('your-package-name'); | ||
searchMcDonaldsSite('Big Mac', 5) | ||
.then(results => { | ||
console.log(results); // Returns up to 5 results | ||
}) | ||
.catch(error => { | ||
console.error(error); | ||
}); |
@@ -54,2 +54,20 @@ // mcdonaldApi.js | ||
module.exports = { getNearestLocation, getLocations }; | ||
async function searchMcDonaldsSite(searchText, resultLimit = 10) { | ||
if (!searchText) { | ||
throw new Error("Missing searchText parameter"); | ||
} | ||
const apiUrl = `https://www.mcdonalds.com/api/mcdcustomsearch.customSearch.json?searchRootPath=%2Fcontent%2Fmcdonalds%2Fus%2Fen-us&searchText=${encodeURIComponent(searchText)}&searchResultLimit=70&type=site`; | ||
try { | ||
const response = await axios.get(apiUrl); | ||
const results = response.data.splice(0, resultLimit).map(food => food.title); | ||
return results; | ||
} catch (error) { | ||
console.error(error); | ||
throw new Error("Something went horribly wrong, McDonald's is probably suspicious of you..."); | ||
} | ||
} | ||
module.exports = { getNearestLocation, getLocations, searchMcDonaldsSite }; |
6633
1
73
87
- Removedexpress@^4.17.1
- Removedaccepts@1.3.8(transitive)
- Removedarray-flatten@1.1.1(transitive)
- Removedbody-parser@1.20.3(transitive)
- Removedbytes@3.1.2(transitive)
- Removedcall-bind-apply-helpers@1.0.2(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removedcontent-type@1.0.5(transitive)
- Removedcookie@0.7.1(transitive)
- Removedcookie-signature@1.0.6(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddepd@2.0.0(transitive)
- Removeddestroy@1.2.0(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedee-first@1.1.1(transitive)
- Removedencodeurl@1.0.22.0.0(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedetag@1.8.1(transitive)
- Removedexpress@4.21.2(transitive)
- Removedfinalhandler@1.3.1(transitive)
- Removedforwarded@0.2.0(transitive)
- Removedfresh@0.5.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.7(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhttp-errors@2.0.0(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedinherits@2.0.4(transitive)
- Removedipaddr.js@1.9.1(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmedia-typer@0.3.0(transitive)
- Removedmerge-descriptors@1.0.3(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmime@1.6.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedms@2.0.02.1.3(transitive)
- Removednegotiator@0.6.3(transitive)
- Removedobject-inspect@1.13.4(transitive)
- Removedon-finished@2.4.1(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedpath-to-regexp@0.1.12(transitive)
- Removedproxy-addr@2.0.7(transitive)
- Removedqs@6.13.0(transitive)
- Removedrange-parser@1.2.1(transitive)
- Removedraw-body@2.5.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsend@0.19.0(transitive)
- Removedserve-static@1.16.2(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedstatuses@2.0.1(transitive)
- Removedtoidentifier@1.0.1(transitive)
- Removedtype-is@1.6.18(transitive)
- Removedunpipe@1.0.0(transitive)
- Removedutils-merge@1.0.1(transitive)
- Removedvary@1.1.2(transitive)