problem with using axios in Laravel 8 | axios is not defined - axios

hello everyone for a realtime laravel application i want to use axios . in app.js file in resources directory I required axios file here is all app.js file codes :
require('./bootstrap');
window._ = require('lodash');
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
the problem is when I want to use axios in frontend it errors that axios is not defined so what the problem ? can someone help me please ...

i realized that in my layout template I forgot delete defer from app.js script and it cause in entire project Axios and Echo libraries not be recognized so after deleted "defer" from script tag it works like a charm

Related

Agora sdk plugin not recognized in Nuxt 2

I'm trying to setup Agora for live streaming in my nuxtjs app. But it gives an error saying plugin not recognized in the console and I can't seem to get past this issue. Did anyone encounter similar issues? My nuxt version is "nuxt": "^2.15.8" and agora "agora-rtc-sdk-ng": "^4.13.0". The error I'm encountering now is:
I've imported the plugin in agora.js file in my plugins folder.
import Vue from "vue";
import { AgoraRTC } from 'agora-rtc-sdk-ng';
Vue.use(AgoraRTC);
And the nuxt config.
{
src: "~/plugins/agora.js",
ssr: false,
mode: 'client'
}
EDIT:
If I update the agora.js file with this code:
import Vue from "vue";
import AgoraRTC from 'agora-rtc-sdk-ng';
Vue.use(AgoraRTC);
I get the error: ReferenceError: AgoraRTC is not defined.
Am I missing something? Also it would be a great help if anyone could give reference to a demo build with nuxt.
After finding no solution to this, I contacted the support team of Agora. They had been a great help!
The problem was with Vue.use(AgoraRTC). For some reason this wasn't working. So I had to inject it in the app.
First I replaced these sections form plugins/agora.js file:
import Vue from "vue";
import AgoraRTC from 'agora-rtc-sdk-ng';
Vue.use(AgoraRTC);
and nuxt.config.js file:
{
src: "~/plugins/agora.js",
ssr: false,
mode: 'client'
}
With this:
import AgoraRTC from "agora-rtc-sdk-ng"
export default ({app}, inject) => {
inject("AgoraRTC", AgoraRTC)
}
and:
{
src: "~/plugins/agora.js",
mode: 'client'
}
Finally the AgoraRTC variable is accessible in the components as this.$AgoraRTC.
Reference to inject in $root from Nuxt docs
Thanks to the support team of Agora

Nuxt Page this.$axios.CancelToken is undefined

I'm trying to get an axios module CancelToken generated using the following on a create hook inside a page.
created() {
const source = this.$axios.CancelToken.source()
...
But I get
TypeError: "this.$axios.CancelToken is undefined"
I can't see what I'm doing wrong and the docs appear to be telling me this works.
https://axios.nuxtjs.org/usage#cancel-token
This was due to the nuxtjs/axios package being too old.
The CancelToken only got added in 5.8.0
https://github.com/nuxt-community/axios-module/releases/tag/v5.8.0

Fetching data from json file in protractor

I am working on protractor testing framework to test the Angular Js application.
I am stuck in a scenario where I want to fetch the data
(eg: Test URL,Username,Password)from external file say Json File.
I have created one json file for this and written code to read the data from this json file but I am getting the error
as:
DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[11:03:10] I/launcher - Running 1 instances of WebDriver
[11:03:10] I/local - Starting selenium standalone server...
[11:03:12] I/local - Selenium standalone server started at http://10.212.134.201:59697/wd/hub
[11:03:15] E/launcher - Error: Error: Cannot find module 'E:LAM WAH EE_Testing EnviornmentDetailed_Sheet - Copy.geojson'
where Detailed_Sheet - Copy.geojson is the file where I have given the url name and username and password.
Please anyone having idea about this help me so that I will get to know where is my mistake.
Please see below example, the example assume we have two files and they are in same folder:
1) login.auth.json, its content as below:
{
"loginurl": "http://172.16.99.47:3001",
"username": "azizi#hlwe.com",
"password": "abcd#1234"
}
Note: For json file, you no need to use module.exports or exports.xxx to export the json data, you only need to write a valid json data in json file and use require() to import, then you will get the json data.
2) test.js, its content as below:
var auth = require('./login.auth.json');
describe('Opne the clinicare website by logging into the site', function() {
it('Should Add a text in username and password fields and hit login button', function() {
browser.driver.manage().window().maximize();
browser.get(auth.loginurl);
//Perform Login:UserName
element(by.model('accessCode')).sendKeys(auth.username);
//Perform Login:Password
element(by.model('password')).sendKeys(auth.password);
//Perform Login:LoginButton
element(by.css('.btn.btn-primary.pull-right')).click();
});
});

gcloud deploy function error code 3

I'm doing the tutorial of basic fulfillment and conversation setup of api.ai tutorial to make a bot for facebook messenger, and when I try to deploy the function with the command:
gcloud beta functions deploy testBot --stage-bucket testbot-e9bc4.appspot.com --trigger-http
(where 'testBot' is the name of the project and 'testbot-e9bc4.appspot.com' is the bucket_name, I thought..)
It return the following error message:
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Source code size exceeds the limit
I've searched but not found any answer, I don't know where is the error.
this is the JS file that appear in the tutorial:
/
HTTP Cloud Function.
#param {Object} req Cloud Function request context.
#param {Object} res Cloud Function response context.
*/
exports.helloHttp = function helloHttp (req, res) {
response = "This is a sample response from your webhook!" //Default response from the webhook to show it's working
res.setHeader('Content-Type', 'application/json'); //Requires application/json MIME type
res.send(JSON.stringify({ "speech": response, "displayText": response
//"speech" is the spoken version of the response, "displayText" is the visual version
}));
};
Make sure you are in the correct directory where your go code resides before executing gcloud beta functions deploy testBot --stage-bucket testbot-e9bc4.appspot.com --trigger-http command.
I was working in the express project. In my case, I mistakenly installed the #google/storage package in devDependencies instead of dependencies. I unable to notice as I tested the project in debug mode using mocha. So in debug, it is able to find that package in devDependencies but on deploy function, it tries to find in dependencies in package.json but unable to find there.
Open command prompt at the location where index.js was created and run the above gcloud command.

Node.js 6.x async/await in required libs with Babel

For some reason I should use Node.js 6.x (actually 6.10.0) and I'm trying to run koa2 with Babel as described here. My code looks like this
const Koa = require('koa');
var app = new Koa();
// --- middlewares ---
async function a(){await 1} // okay here!
console.log(a());
const serve = require('koa-static');
app.use(serve('./web'));
app.use(require('koa-cookie').default());
app.use(require('koa-bodyparser')()); // fails here
And I'm getting error
D:\Project\node_modules\koa-bodyparser\index.js:72
return async function bodyParser(ctx, next) {
^^^^^^^^
SyntaxError: Unexpected token function
Running node with nodemon index.js --exec babel-node on Windows
Works perfect on Node 7.x, but I need to use 6 unfortunately :(
async and await are not yet supported in Node.js 6.x. They are ES2017 features and are only supported in Node 7.6+.
The Babel preset you're using is obviously not working - make sure you are using the correct babel preset (ES2017) as per the instructions on the Babel site.