I'm making an web app by using webpack, angularjs and bluebird.
I put this in my code:
{
"plugins":[
{
new webpack.ProvidePlugin({Promise: 'bluebird'})
}
]
}
But in developer console. Promise doesn't appear as a global variable. When I tried using it, console said: 'Promise is undefined'
Can anyone help me please?
Thank you,
Related
I have been developing a browser extension in vaniall JS till now. I would like to use vite + Vue moving forward. Upon doing a google search I found this GitHub repository which help with this.
I'm trying to set the user preferences and save them in storage using storage.sync. But when I use browser.storage.sync.get, I get below error
Cannot read properties of undefined (reading 'sync')
How to solve this? What is the correct way to use storage.sync with
webextension-polyfill or #types/webextension-polyfill
Below is the code is have using vanilla js with is woring perfectly
chrome.storage.sync.get({ 'testData': MyTestData }, result => {
console.log(result);
})
Below is the way to use storage.sync using webextension-polyfill
import browser from "webextension-polyfill";
browser.storage.sync.set({ 'testData': MyTestData }, result => {
console.log(result);
})
I am trying to implement google pay on a website. The external library for google pay is loaded from pay.google.com. In this google script, they call the browser api PaymentRequest(). This api is built in popular browsers like Safari, Chrome, etc.
I have google pay working, but it does not work on Firefox. When the external script is loaded, it calls PaymentRequest and in the console the following error is shown:
ReferenceError: PaymentRequest is not defined
Link to google pay script
https://pay.google.com/gp/p/js/pay.js
Mozilla Firefox official webpage states that PaymentRequest is supported in secure context.
https://developer.mozilla.org/en-US/docs/Web/API/Payment_Request_API/Using_the_Payment_Request_API
I copy and paste only the same code provided from the official source
From my perspective, PaymentRequest is not supported in Firefox and does not work. What am I missing?
Check out the console for both chrome and safari.
Google Pay is working for me on Firefox 78.0.1 on macOS using the following: https://jsfiddle.net/fw5t6caL/
Yes, it does log an error in the console at the following bit of code:
google.payments.api.UseCanMakePaymentResultFromPayjs && (new PaymentRequest([{
supportedMethods: [
'https://google.com/pay'
]
}
], {
total: {
label: 'Estimated Total Price',
amount: {
currency: 'USD',
value: '10'
}
}
})).canMakePayment().then(function (a) {
return ef = a
}).catch (function () {
return ef = !1
});
...but it does work. Are you able to try with the JSFiddle linked above?
Also, as an FYI, we've recently released a React and Web Component to simplify the Google Pay integration process. Consider using it as an alternative as it should make it easier to integrate.
Screenshot of JSFiddle output:
I am having the same Problem since a few days:
Uncaught ReferenceError: PaymentRequest is not defined
https://pay.google.com/gp/p/js/pay.js:272
This happens (I believe) in the Stripe Plugin for WooCommerce. The Error appears in Chrome and Firefox. No Idea at the Moment what I can do to fix it.
I'd like to render GraphQL Playground as a React component in one of my pages but it fails due to missing file-loader in webpack. Is there a way to fix this in docs or do I need to create new plugin with new webpack config?
Is it good idea to integrate Playground and Docusaurus at all?
Thanks for your ideas...
A few Docusaurus sites have embedded playgrounds:
Hermes
Uniforms
In your case you will have to write a plugin to extend the webpack config with file-loader.
Not sure if you found a better way but check out: https://www.npmjs.com/package/graphql-playground-react
You can embed this react component directly in your react app - It looks like Apollo also uses the vanilla JS version of this
I just had exactly the same problem. Basically, Docusaurus with a gQL Playground Integration runs fine in local but won't compile due to errors when running yarn build as above.
In the end I found the answer is in Docusaurus, not in building a custom compiler:
I switched from using graphql-react-playground to GraphiQL: package: "graphiql": "^1.8.7"
This moved my error on to a weird one with no references anywhere on the web (rare for me): "no valid fetcher implementation available"
I fixed the above by importing createGraphiQLFetcher from '#graphiql/create-fetcher' to my component
Then the error was around not being able to find a window component, this was an easy one, I followed docusaurus docs here: https://docusaurus.io/docs/docusaurus-core#browseronly and wrapped my component on this page in like this:
import BrowserOnly from '#docusaurus/BrowserOnly';
const Explorer = () => {
const { siteConfig } = useDocusaurusContext();
return (
<BrowserOnly fallback={Loading...}>
{() => {
const GraphEx = GraphExplorer
return
}}
);
}
This now works and builds successfully
It looks like Vuepress is made for public docs, but we decided to add client and server security to protect some of the doc pages. But unfortunately although oidc-client (https://github.com/IdentityModel/oidc-client-js/wiki) works during dev, it throws exception when build.
I get ReferenceError: window is not defined and when I try to trick the compiler with const window = window || { location: {} }; I get TypeError: Cannot read property 'getItem' of undefined
Any idea how to make this work?
This was driving me nuts also. I discovered the component I was trying to add was looking at window.location in its code - this was triggering the error.
My understanding is that the build process has not access to Browser things like window etc.
As soon as I removed the window.location bit from my code things built just fine and all is well.
My drupal developer given a url like:http://feed.local/feed/services/rest/viewget/test.json
then am getting the out put as(when am browsing from chrome browser) below:
[{"nid":"133","node_title":"What is life really all about?"},{"nid":"139","node_title":"What went wrong?"}]
I am using sumitk tutorial that is how to develop iphone app using drupal as base system with titanium.
My problem is how can i parse the above in titanium .Can any one help.....
Or else If any one help me how can i use this in xcode........
You can use Titanium.JSON.parse
JSON.parse will help you, it is a function included by Titanium. Make sure you encapsulate it within a try {} catch(excp) {}
For example:
try
{
var data = JSON.parse('[{"nid":"133","node_title":"What is life really all about?"},{"nid":"139","node_title":"What went wrong?"}]');
}
catch (excp)
{
alert('JSON parse error');
}