Fix incorrect use of static Inventaire URL
This commit is contained in:
parent
8f0edf7e01
commit
963049e4c8
|
@ -2,12 +2,11 @@ const fetch = require('node-fetch');
|
||||||
|
|
||||||
class Inventaire {
|
class Inventaire {
|
||||||
constructor(language = 'en') {
|
constructor(language = 'en') {
|
||||||
this.url = 'https://inventaire.io';
|
|
||||||
this.lang = language;
|
this.lang = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getURL() { // Use a method instead of `get` to avoid collisions with `this.url`
|
static get url() {
|
||||||
return this.url;
|
return 'https://inventaire.io';
|
||||||
}
|
}
|
||||||
|
|
||||||
static handleQuickEntity(entityObject) {
|
static handleQuickEntity(entityObject) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ const fetch = require('node-fetch');
|
||||||
const Inventaire = require('../bookData/Inventaire');
|
const Inventaire = require('../bookData/Inventaire');
|
||||||
|
|
||||||
function quickSearchInventaire(searchTerm, language) {
|
function quickSearchInventaire(searchTerm, language) {
|
||||||
const request = fetch(`${Inventaire.getURL()}/api/search?types=works&search=${encodeURIComponent(searchTerm)}&lang=${encodeURIComponent(language)}&limit=10`)
|
const request = fetch(`${Inventaire.url}/api/search?types=works&search=${encodeURIComponent(searchTerm)}&lang=${encodeURIComponent(language)}&limit=10`)
|
||||||
request.catch(exception => {
|
request.catch(exception => {
|
||||||
console.error(exception);
|
console.error(exception);
|
||||||
return {
|
return {
|
||||||
|
@ -27,7 +27,7 @@ function quickSearchInventaire(searchTerm, language) {
|
||||||
|
|
||||||
function searchInventaire(searchTerm, language) {
|
function searchInventaire(searchTerm, language) {
|
||||||
if (this.hasQuery) {
|
if (this.hasQuery) {
|
||||||
const request = fetch(`${Inventaire.getURL()}/api/entities?action=search&search=${encodeURIComponent(searchTerm)}&lang=${encodeURIComponent(language)}`)
|
const request = fetch(`${Inventaire.url}/api/entities?action=search&search=${encodeURIComponent(searchTerm)}&lang=${encodeURIComponent(language)}`)
|
||||||
request.catch(exception => {
|
request.catch(exception => {
|
||||||
console.error(exception);
|
console.error(exception);
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue