-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moving promises to asyc/await * Cleaning up file * Edit examples * fix up Co-authored-by: Sean Thomas Burke <[email protected]>
- Loading branch information
1 parent
e96d14d
commit 6104d68
Showing
7 changed files
with
154 additions
and
106 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 |
---|---|---|
@@ -1,27 +1,41 @@ | ||
import Sitemapper from 'sitemapper'; | ||
|
||
const sitemapper = new Sitemapper(); | ||
(async () => { | ||
const sitemapper = new Sitemapper(); | ||
|
||
const Google = new Sitemapper({ | ||
url: 'https://www.google.com/work/sitemap.xml', | ||
debug: false, | ||
timeout: 15000, // 15 seconds | ||
}); | ||
const Google = new Sitemapper({ | ||
url: 'https://www.google.com/work/sitemap.xml', | ||
debug: false, | ||
timeout: 15000, // 15 seconds | ||
}); | ||
|
||
Google.fetch() | ||
.then(data => console.log(data.sites)) | ||
.catch(error => console.log(error)); | ||
try { | ||
const data = await Google.fetch(); | ||
console.log(data.sites); | ||
} catch(error) { | ||
console.log(error); | ||
} | ||
|
||
sitemapper.timeout = 5000; | ||
sitemapper.timeout = 5000; | ||
|
||
sitemapper.fetch('https://wp.seantburke.com/sitemap.xml') | ||
.then(({ url, sites }) => console.log(`url:${url}`, 'sites:', sites)) | ||
.catch(error => console.log(error)); | ||
try { | ||
const { url, sites } = await sitemapper.fetch('https://wp.seantburke.com/sitemap.xml'); | ||
console.log(`url:${url}`, 'sites:', sites); | ||
} catch(error) { | ||
console.log(error) | ||
} | ||
|
||
sitemapper.fetch('http://www.cnn.com/sitemaps/sitemap-index.xml') | ||
.then(data => console.log(data)) | ||
.catch(error => console.log(error)); | ||
try { | ||
const { url, sites } = await sitemapper.fetch('http://www.cnn.com/sitemaps/sitemap-index.xml'); | ||
console.log(`url:${url}`, 'sites:', sites); | ||
} catch(error) { | ||
console.log(error) | ||
} | ||
|
||
sitemapper.fetch('http://www.stubhub.com/new-sitemap/us/sitemap-US-en-index.xml') | ||
.then((data) => console.log(data)) | ||
.catch(error => console.log(error)); | ||
try { | ||
const { url, sites } = await sitemapper.fetch('http://www.stubhub.com/new-sitemap/us/sitemap-US-en-index.xml'); | ||
console.log(`url:${url}`, 'sites:', sites); | ||
} catch(error) { | ||
console.log(error) | ||
} | ||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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