New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mcdonald-location-apiv2

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mcdonald-location-apiv2 - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

3

package.json
{
"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 };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc