score:1
if you are certain that the values will always be in their given position. you can do something like
const clusterid = href.split('/')[5]
const analysisid = href.split('/')[7]
score:1
if you know what's the keyword that precedes your id:
const getvalue = (string, id) => {
const stringarray = string.split("/");
const index = stringarray.indexof(id);
return stringarray[index + 1];
}
clusterid = getvalue(json[0].analysisunits.links[0].href, "clusters");
analysisid = getvalue(json[0].links[0].href, "aus");
Source: stackoverflow.com
Related Query
- How to retrieve a value from API in react js
- How to correctly type a null value in typescript react app, retrieved from an JSON object (api call) when using Object.entries to retrieve the value?
- How do I load API data into input value property on page load from React State?
- How to type initial value in React Context of object data fetched from API
- React | How to interpolate value from an input into API call
- How to sort a complicated date value in react js table from the api
- How do I pass value from my react component to my express API calls ?
- How to Make A second API call based on the value gotten from the first. with React and useEffect hooks
- Retrieve a particular value from Rest Api using react js
- How to return value from an API call in javascript to a React component
- how to make react checkbox disabled when value from api is true
- How to access forgin key value in react from django api
- How to display different value from the api on radio button click in react js.?
- How to set/change Field value from external user action 🏁 React Final Form
- React Hooks - How to get parameter value from query string
- How can I set initial React state from API data?
- React Formik Material UI Autocomplete: How can I populate value inside of autocomplete from localStorage?
- React Navigation: How to update navigation title for parent, when value comes from redux and gets updated in child?
- How to get value from a react function within a react component
- React Select - How to show / iterate through data from api call in option instead of hardcoding options?
- How to handle side effects when migrating from Redux to React Context API + hooks
- How to use react ref to get value from html select element?
- Setting a default value on a react select dropdown that is populated from an API call
- How can I cache data from API to Cache Storage in React PWA?
- React Final Form. How to set field value from component state
- How to pass input value from child to parent component react
- How can I get the value from an animated or interpolated value in React Native?
- How to redirect to 404 if no data from external API (universal React + Redux app)?
- How retrieve current redux-form state field value in react class form component?
- How to get the selected value from a radio button group in React where there are multiple groups?
More Query from same tag
- I am trying to use image in a card component using map function in js.Everything except the image is working fine
- change icon tag with javascript
- Converting a stateful component to stateless
- Accessing Object ReactJS
- Why does not my onClick event work?
- Module build failed: SyntaxError: Unexpected token regarding quotation marks
- Displaying components from API in an efficient way
- While doing form validation on submit a form, the component is not updating in React
- Join array with svg in jsx
- Use setinterval in React
- Warning: Failed prop type: Invalid prop `value` supplied to `ForwardRef(Slider)`
- return this returns undefined
- React-Router - Link to the same page not triggering page unMount
- React Typescript onChange function typeError
- react-bootstrap breadcrumb with react-router-dom
- How to filter a nested array with custom key in React / Javascript
- Publish as npm library to github with source code but on install should get the files present in dist
- Express session always creating new session when making get/post request from react js
- Mock-axios-adapter not mocking get request
- White space appears after calling a Route even though height is set to 100vh
- How to pass one state the component father to component child to open a modal React
- Why isn't this react component updating with mobx observer
- TS2339 when trying to conditionally disable a link
- displaying a sucess message using email.js
- Closing webcam without reloading
- How to ensure I am reading the most recent version of state?
- How to combine React-Spring useTrail and useTransition on same elements?
- React TypeError: Cannot read properties of undefined (reading 'state')
- React context is undefined
- I am trying copy the image to canvas using the html2canvas but its not working