Uncaught (in promise) Error: Error: Adapter 'http' is not available in the build - reactjs

I am trying to use axios in React chrome extension module, but I am facing this issue.
Uncaught (in promise) Error: Error: Adapter 'http' is not available in the build
// background.ts
import axios from "axios"
...
axios.get<SerInyResponse>("https://realtor.p.rapidapi.com/locations/v2/auto-complete")
.then(response => {
this.Storage.setLocalStorage(response.data).then( (re) => {
resolve(response.data.Listeners)
})
})
.catch( err => {
reject(new Error(err))
})
Can anyone help me?

Related

Axios api call gives Network error while fetch() works well

I'm a react native beginner. I'm trying to make a simple http get request using axios.
Here is my axios configuration:
import axios from 'axios';
export default axios.create({
baseUrl: 'https://blobrfishwebapi.azurewebsites.net',
});
And this is how I make the request using my configured axios:
import configuredAxios '../api/configuredAxios';
const response = await configuredAxios
.get('/employer/jobposts/recenttest')
.then(res => res.data)
.then(({data, isSuccessful, message}) => {
if (!isSuccessful) {
throw new Error(message);
}
setjobPostings(data);
})
.catch(err => {
console.log(JSON.stringify(err, Object.getOwnPropertyNames(err)));
});
This is the error I get when I make the above call:
{"stack":"Error: **Network Error**\n at createError (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.blobfshemployer&modulesOnly=false&runModule=true:98386:17)\n at XMLHttpRequest.handleError (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.blobfshemployer&modulesOnly=false&runModule=true:98196:69)\n.....
Finally, same endpoint call using fetch() which returns a 200 status code:
let response = await fetch(
'https://blobrfishwebapi.azurewebsites.net/employer/jobposts/recenttest',
);
let json = await response.json();
setjobPostings(JSON.stringify(json, Object.getOwnPropertyNames(json)));
catch(
err => console.log(JSON.stringify(err, Object.getOwnPropertyNames(err))),
console.log('error'),
);
Has anyone experienced a similar problem using axios?
I'm running my app on an android emulator, axios version is 0.21.4, react native version is 0.70.4.
Thanks in advance.
Rookie error! The "baseUrl" property of my axios config object should have the "url" part capitalized:
import axios from 'axios';
export default axios.create({
base**URL**: 'https://blobrfishwebapi.azurewebsites.net',
});

Cordova OneSignal Sdk not working in React Capacitor Project

I'm getting this error
TypeError: window.OneSignal.push is not a function
in the latest SDK and Cordova plugin. But when I downgraded the onesignal-cordova-plugin to 2.11.3 I get a plugin_not_installed error.
import React from "react";
import { OneSignal } from "#awesome-cordova-plugins/onesignal";
React.useEffect(()=> {
OneSignalInit();
}, [])
const OneSignalInit = async () => {
OneSignal.startInit(import.meta.env.VITE_ONESIGNAL_APPID, import.meta.env.VITE_GOOGLE_PROJECT_ID); // Error: TypeError: window.OneSignal.push is not a function
};
Package JSON:

how do I instantiate web3 for my typescript project?

please, I am working on a project with typescript and vite, and I need to load web3.js but it is failing to instantiate.
This is the code I used below
import Web3 from 'web3'
const loadWeb3 = async () => { web3 = new Web3(window.ethereum); await window.ethereum.enable(); };
then the error it gives me is as follows:
`util.js:109 Uncaught ReferenceError: process is not defined
at node_modules/util/util.js (util.js:109:1)
at __require2 (chunk-JXMXRRTK.js?v=cedb61c3:35:50)
at node_modules/web3-core-requestmanager/lib/index.js (index.js:20:25)
at __require2 (chunk-JXMXRRTK.js?v=cedb61c3:35:50)
at node_modules/web3-core/lib/index.js (index.js:22:24)
at __require2 (chunk-JXMXRRTK.js?v=cedb61c3:35:50)
at node_modules/web3/lib/index.js (index.js:29:12)
at __require2 (chunk-JXMXRRTK.js?v=cedb61c3:35:50)
at dep:web3:1:16`

Module build failed: SyntaxError When i try for asyncComponent in Laravel + React

I want to implement asyncComponent in laravel + react. Everything work Good before i tried asyncComponent.
When i try that return error :
Code :
import asyncComponent from '../component/asyncComponent';
const Home = asyncComponent(() => import('../pages/home') //line 9
.then(module => module.default), { name: 'Home' });
Error:
Module build failed: SyntaxError:
E:/xampp/htdocs/react/lara-react/blog-new/resources/js/back-end/layout/main.js:
Unexpected token (9:34)
How to implement asyncComponent in laravel ?

function is not defined error in react-scroll

import * as Scroll from 'react-scroll';
componentDidMount() {
Scroll.Events.scrollEvent.register('end', () => {
this.checkScrollForMobile();
});
checkScrollForMobile(){}
Getting "Uncaught ReferenceError: checkScrollForMobile is not defined" error though I've defined it below. Please help.

Resources