Skip to content

Commit

Permalink
#1 create entry in my memory translation service
Browse files Browse the repository at this point in the history
  • Loading branch information
Patryk Wychowaniec committed Aug 13, 2020
1 parent 7c90582 commit 8feef0d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/translate/MyMemoryTranslateService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fetch = require('node-fetch');

const TranslateService = require('./TranslateService');
const dictionaryService = require('../dictionaryService');

const API = 'https://api.mymemory.translated.net/get';

Expand All @@ -13,7 +14,11 @@ class MyMemoryTranslateService extends TranslateService {

fetch(URL)
.then(data => data.json())
.then(data => resolve(data.responseData.translatedText))
.then(data => {
const translatedText = data.responseData.translatedText;
this.log.addEntry(key, to, translatedText);
resolve(dictionaryService.createEntry(key, translatedText));
})
.catch(err => reject(err));
});
}
Expand Down

0 comments on commit 8feef0d

Please sign in to comment.