README
Installation
npm i odrabiamy-pl
Usage
const odrabiamy = require('odrabiamy-pl')
Asynchronous Examples
If you're able to use await/async, using this package will be a lot easier. Below are some of the usage examples.Get list of all books
const odrabiamy = require('odrabiamy-pl')
let class_id = 1 // min. 0, max. 9
let books = await odrabiamy.GetBooks(class_id)
console.log(books) //Print out the array
Filter out a number from a string
const odrabiamy = require('odrabiamy-pl')
let example_string = "exercise 17"
let number_string = await odrabiamy.SanitizeString(example_string)
console.log(`Sanitized string: ${number_string}`) //Print out the filtered variable
Return an exercise
const odrabiamy = require('odrabiamy-pl')
let book_link = "https://odrabiamy.pl/biologia/ksiazka-11212"
let exercise_number = "1"
let page_number = "4"
let result = odrabiamy.GetExercise(book_link, exercise_number, page_number)
if(result.Error) //Error. You can use result.Code to figure out what went wrong
{
if(result.Code == 200)
console.log(`Page not found, Code ${result.Code}`)
else if(result.Code == 201)
console.log(`Exercise not found, Code ${result.Code}`)
else if(result.Code == 500)
console.log(`Unknown error, Code ${result.Code}`)
}
else
{
console.log(`Success! Exercise code: ${result.Code}, Filepath: ${odrabiamy.GetFilepathFromCode(result.Code)}
}
Synchronous example
Promises are supported. That means you can use .then freelyExample below will return an array of books without using await/async
Get list of all books
const odrabiamy = require('odrabiamy-pl')
let class_id = 1 // min. 0, max. 9
odrabiamy.GetBooks(class_id).then((books) => {
console.log(books) //Print out the array
})