October 22, 2024
Chicago 12, Melborne City, USA
javascript

How do I return the response from an asynchronous call?

I’m trying to convert a small (single page) PHP app to Javascript but having trouble accessing the contents of the JSON file. I think it’s down to how I’ve written the JS, but as an example: async function fetchLocalFile(filePath) { try { const response = await fetch(filePath); if (!response.ok) { throw new Error(`HTTP error! status:

Read More
javascript

How do I tell Google when page finishes loading with React Router?

Accordinly GSC, for the page https://zoncircle.com/item/5@xxu7o-ziaaa-aaaak-qinrq-cai the "User-declared canonical" is itself what is correct, but "Google-selected canonical" is https://zoncircle.com/item/2@xxu7o-ziaaa-aaaak-qinrq-cai what is wrong. My guess is that Google reads https://zoncircle.com/item/5@xxu7o-ziaaa-aaaak-qinrq-cai before my code reacts to URL change and therefore before it loads new texts, so Google uses the text from previously loaded Router page. How using

Read More
javascript

puppeteer nodejs, cant take the value outside of the evaluate scope

I have a puppeteer program, which i get the element of a div, and then process its children. When I try to log with console.log(), I can inspect and see the value on browser. Yet on node js, console, I can’t see the value that was supposed to be pushed to the array. This is

Read More
javascript

display button into html form failed with initialize

My script doesn’t work well. When the button “b5” clicked with ouside <form …> … element, the buttons b5 and b4 deseapper and the buttons b1,b2,b3 appear. This work normaly when my code about button is not inside the <form …> … element… When i put inside and i press or click the button b5,

Read More
javascript

Using OpenAI's real-time api with server-vad mode

I’m trying to setup the real-time api, but I’m a little confused on how the audio to audio events are suppose to work in server_vad mode. Currently I do the following: setup the real-time client const client = new RealtimeClient({ apiKey: process.env.OPENAI_API_KEY }); set the client session: instructions: "be nice and helpful", input_audio_transcription: { model:

Read More
javascript

Azure Function App – No HTTP triggers found (works fine locally)

I’m looking to create a relatively simple javascript app that runs on node as an azure function app and will eventually return a generated png. I installed the Azure Function extension to get me going with a really simple hello world app. I published this to azure and it works fine. The issue is –

Read More
javascript

Running into “Target page, context or browser has been closed” issue

The below code is my Playwright test function test("@Login @Testing Sign In Page Test", async ({ page }) => { console.log("Sign In Page Test"); const pageManager = new pageObjectManager(page); const homePage = pageManager.getHomePage(); const loginPage = pageManager.getLoginPage(); const signInPage = pageManager.getSignInPage(); // await homePage.goToHomePage(); await page.goto("https://magento.softwaretestingboard.com/"); // await loginPage.goToSignInPage(); console.log(await page.title()); await page.locator("//li[@class="authorization-link"]").first().click(); // await

Read More
javascript

Copy response from Chrome Dev tools network tab

I am working with Typescript React.I want to copy paste a response into my react code as a mock-file.But when I copy from Network tab, the JSON response’s keys are in double quotes.I want to convert this JSON response to a pure JavaScript object so that folding and unfolding works in my vs code. When

Read More
javascript

Creating and using dynamic variables based on a dynamic component

I have a table as a component, and now I am trying to build a column wise search within it. The table that will be created will have a dynamic number of columns. Hence I need to create multiple variables for binding with the search input. I was trying to create those variables with eval

Read More
javascript

Fake 'Please select a variation' alert on Add to Cart button in WooCommerce product variation selection

I’m working on a custom WooCommerce product page where the user can select product variations (like size, color, etc.) and then add the product to the cart. Everything is functioning correctly, including the variation selection and the dynamic price update based on the selected variation. However, I’ve encountered a problem. When a user selects a

Read More