score:0
Accepted answer
i just figured out how it's done, sry guys
this how i do it
let secfilm = result.data.films
let secpilot = result.data.pilots
function secure(arr){
for (let k = 0; k < arr.length; k++) {
arr[k] = arr[k].replace(/http/g, "https");
}
}
secure(secfilm, secpilot)
so i don't have to make async function, thank you to @thomas i know it's not the best method, but i think it's better than before
score:0
function converthttp(arr=[]) {
arr.foreach((val, index, arr) => {
arr[index] = val.replace(/http/g, "https");
});
}
i guess you don't need an async function instead you can use the above function if u need to change object value everywhere otherwise you can use a map function which creates a new array of value containing https and the original array also will be retained with http
map function
function converthttp(httparr=[]) {
return httparr.map(val => val.replace(/http/g, "https"));
}
correct me if i am wrong. thank you
Source: stackoverflow.com
Related Query
- make a function with async call
- how to make async call in react-redux hooks with thunk?
- Apollo React call async function with query result
- How to sequentially call an async function in various time intervals and with different arguments
- ReactJS : Async function with axios call makes axios call in componentDidUpdate to return promise
- How can I store the value of an async function to be used multiple times in a function without having to make the async call multiple times?
- how to call function with async await in React function, so I can get the result by sequentially
- How to call loading function with React useEffect only once
- Where can I make API call with hooks in react?
- How to call an async function inside a UseEffect() in React?
- How to test useEffect with async function and setState inside
- Testing with React's Jest and Enzyme when simulated clicks call a function that calls a promise
- Trying call useQuery in function with react-apollo-hooks
- Is it possible to call an async function inside a constructor in react-native?
- Is possible to call async function without await keyword? and what happens if we call without await?
- useState with async function returning PromiseĀ {<pending>}
- Unable to call child function from parent using refs with functional component
- How to load React-select Async with initial options for edit item function when using a search API?
- react functional component with ag grid cannot call parent function via context
- Recompose "withReducer": justification of async reducer function call
- getInitialProps does not work with async function
- How to call Parent function with useState Hook in React?
- How to call a function after all async calls in loop are done?
- useSWR doesn't work with async fetcher function
- How to call a function every x seconds with updated state (React)
- Rendering part of a React function component after async call gets completed
- Jest unit test - How do I call through async function in a setTimeout repeating function
- How do i properly use useEffect for a async fetch call with react? react-hooks/exhaustive-deps
- Stateful React component with async function failing Jest test
- How to make a react component with Async data re-usable in Redux flow?
More Query from same tag
- Access to outer react component from referenced component
- Render component inside Tabs after .map function return
- How do we add -webkit-transform property in css in js?
- How to provide props to custom route in react-admin?
- Is there way to track user current location within service workers in PWA while app is in sleep mode?
- React how to get item props from event.currentTarget
- Google-maps-react: Value of props passed by parent component
- Moment Js Date Comparison
- TypeError: Cannot read property 'length' of undefined, API TMDB
- TypeScript(Nodejs error) Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string
- How to upload image using javascript fetch api and express multer
- returning component inside function not working
- Cannot update the state of an object within the state (react)
- Creating an array from dynamically updating arrays
- How do you programmatically update query params in react-router?
- Update components based on props
- How can i update the counter state each click?
- API won't return data
- How to pass props inside of Router while using React Context
- React change state based on select option
- What does React Native use to allow JavaScript to be executed on iOS and Android natively?
- ReactJS Preload Navigation Elements
- How do I render and replace changes to a specific tag in React?
- How to organise "sub-applications" with redux?
- How to destructure a json object into another json object?
- TypeError: _enzyme2.default.configure is not a function
- How can I hide a table when tbody is empty?
- How to assign value to a state inside a map function of a reducer
- Replace src path in script tag
- How do i output the logs from log file instead of application log