1
0
mirror of https://github.com/teoxoy/factorio-blueprint-editor.git synced 2024-12-26 20:54:22 +02:00

Add the ability to fetch blueprint data from https://www.factorio.school/api/blueprintData (#250)

* Add the ability to fetch blueprint data from https://www.factorio.school/api/blueprintData

* Use href

---------

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
This commit is contained in:
Craig P. Motlin 2023-05-12 19:25:36 -04:00 committed by GitHub
parent 0bec144b89
commit fd197792d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -196,6 +196,10 @@ function getBlueprintOrBookFromSource(source: string): Promise<Blueprint | Book>
.then(r => r.json()) .then(r => r.json())
.then(data => data.blueprintString) .then(data => data.blueprintString)
case 'factorio': // factorio.school case 'factorio': // factorio.school
if (pathParts[0] === 'api') {
return fetchData(url.href).then(r => r.text())
}
return fetchData(`https://www.factorio.school/api/blueprint/${pathParts[1]}`) return fetchData(`https://www.factorio.school/api/blueprint/${pathParts[1]}`)
.then(r => r.json()) .then(r => r.json())
.then(data => data.blueprintString.blueprintString) .then(data => data.blueprintString.blueprintString)