Comments (2)
@Seu07 I'm not very experienced with react native, but I'm pretty sure react-native-blob-util
can be used to polyfill xhr requests with trusty: true
then you can do something like this with Axios:
import { translate } from 'google-translate-api-x';
import axios from 'axios';
function proxiedFetch(url, init) {
// we essentially need to emulate fetch behavior with axios
const axiosOptions = init.requestOptions ?? {};
axiosOptions.data = axiosOptions.body; // axios calls the `body` in fetch `data`
axiosOptions.proxy = {
protocol: 'https',
host: PROXY_URL,
port: '5353', // or whatever port
auth: { // if your proxy needs it
username: PROXY_USERNAME,
password: PROXY_PASSWORD,
},
};
axios.transformResponse = res => res; // prevent axios from parsing json by default
return axios(url, axiosOptions).then(res => {
if (res.status >= 200 && res.status < 300) {
res.ok = true;
} else {
res.ok = false;
}
res.text = () => res.data;
res.json = () => JSON.parse(res.data);
return res;
});
}
const res = await translate('cat', {from: 'en', to: 'es', requestFunction: proxiedFetch});
console.log(res);
Please let me know if you get it to work!
from google-translate-api.
Related Issues (20)
- It throws error "fetch is not defined" HOT 2
- Tests fail only because rate limited on single translate HOT 1
- TypeError: (0 , _googleTranslateApiX.translate) is not a function HOT 17
- google-translate-api-x gives below error HOT 3
- Improve `speak` testing
- Caught an error from batch translate HOT 8
- ERROR [TypeError: Cannot convert null value to object] HOT 2
- Issue with the speak functionality HOT 2
- Batch translation error HOT 6
- Can't run on React.js HOT 2
- Big translation slowed down HOT 11
- change speak speed HOT 2
- fetch is not defined after deployment HOT 2
- CORS policy error HOT 4
- Obtain translation synonyms HOT 1
- How to translate image HOT 2
- Discrepancy with Google Translation HOT 7
- Autocorrect example provides different output HOT 1
- `res.from.language.didYouMean` is always true HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-translate-api.