Skip to content

how to sort recursively in JS

I’m trying to sort an Array type data recursively. Here’s the data structure. I wanna sort by either ‘id’ or ‘name’. This is what I tried. In my poor logic, it seems working but not properly working. Because item’s children or children’s children is not sorted. …

How to target only the number of this with javascript

How can i target only the number of this bdi without the currency simble with Javascript? Answer Update a child node’s textContent. Depending on the currency, the index will be either 1 or 2. In your case it’s 2, because the currency symbol is before the amount. example: The index 0 is skipped bec…

Load SVG into canvas to get base64 dataurl

I have this SVG in my html : the symbol pointed by the “use” tag is : This display correctly when the page load (ie. it is using the symbol that I refer to using use tag). I want to take this SVG and get the base64 dataurl (convert it to an image). I tried to use this code without

Strapi v4 throwing cors exception

Im new to strapi and I have downloaded strapi v4 and as front-end I use vue.js. Now I created categories and I am trying to fetch those with my vue app but I’m getting a cors error. In the documentation I see I can override the origin on the cors middleware, but I don’t know how. I’ve tried it with

strapi 4 populate when update

Is there an way to populate the field when updating, Answer You can do this, by attaching the populate=[your_relational_field] as the query string in the http PUT request call. Sample request http://localhost:1337/api/cart/2?populate=category Sample request body in JSON format That’s all! You don’…

Update UI within .map() when condition changes?

I have a array posts, and a separate array favourites. I want the UI to display “Favourited: [Yes or No]” depending on if favourites includes the value from posts. The problem is when I add to favourites the UI never updates. I made a minimal example here: https://codesandbox.io/s/usestate-useeffe…