score:2
Accepted answer
formdata isn't the best choice here as that is primarily used in constructing multipart/form-data
request payloads for use in post
, put
and patch
requests.
use urlsearchparams instead to easily construct query parameters and serialise it into the url...
const fetch = function fakefetch(url, init) {
console.log(init.method, url)
}
const solutestate = "cc(c)(c)br"
const solventstate = "cc(c)(c)o"
const params = new urlsearchparams({
solute: solutestate,
solvent: solventstate
})
fetch(`http://ihub-fastapi-solubility.herokuapp.com/predict?${params}`, {
method: "get"
})
using urlsearchparams
has the added benefit of correctly url encoding your data.
Source: stackoverflow.com
Related Query
- How to send form data through get request in fetch api
- How to pass form data to an api GET request in React
- How to fetch data through api in redux?
- How to update the state after a data update through an API request in React?
- How to get Laravel CSRF-token for sending it through fetch post request in React?
- How to get React to re fetch my data from API after a POST or DELETE to Database?
- failed to send a get request using fetch api
- how to disable fetch API to send OPTIONS request with Content-Type header?
- How do I render the my latest data through GET request after submitting a POST request
- I want to send the data from a request form to a database in the MySQL workbench from a javascript file in a ReactJs project, but I have no idea how
- How to use for loop in reactjs to send data to get request in flask
- how fetch data from database through api using axios in reactjs?
- How to send data using fetch and POST request with credentials included?
- How to save a list of json data that i get from an API to a class property using fetch
- How to call GET api to send data in BODY using axios?
- Can't get multiple data from API using foreach loop with Fetch API get request
- How to send array and boolean data in body of POST request of API
- How can I fetch data from an array of objects, pass it through an API end point to .fetch() the needed object value using React?
- How to send user data and its profile image using POST request from axios api to Django Rest Framework?
- Please help me how to get data from api with a json body in GET request
- How to send data (from Reactjs) through a class based API (Django Rest Framework)
- How to Fetch JSON data from GET Request FLASK-Python
- How do I get the rendered ID to use globally as a variable to send an API request in React?
- how to send data in GET request header using react and axios to Django rest framework?
- How i get response data from api url usinf fetch in reactjs
- axios post request to send form data
- How to fetch API data from Axios inside the getServerSideProps function in NextJS?
- ReactJS: how to call useEffect hook only once to fetch API data
- How to get a downloadable file from a readableStream response in a fetch request
- How to send body data and headers with axios get request?
More Query from same tag
- How do I add pictures from my assets folder to my React Application?
- How can I get an item in the redux store by a key?
- I am not being able to change the state of my state objects in React.js
- useEffect dependency array continuously calls api data
- What is the best way to add _.throttle on a react element?
- How to render two different arrays data into a single array of objects?
- error rendering facebook react with java (clojure) in the server: Cannot read property "__reactAutoBindMap"
- how to use react-router for dynamic url
- Dispatched and re-rendered callback?
- Run useEffect only one when a special property changed
- addEventListeners and React not working as planned
- Redux: mapStateToProps is rendering twice
- Types of parameters 'event' and 'event' are incompatible
- I'm trying to display data that i fetched from my local server but I receive an error
- trying to pass a value from child component to the parent component in react js
- Jest - how to mock a function which is invoked in module creation
- How to pass values from child component to parent in ReactJS
- Bootstrap form spacing issues with form-inline and form-group?
- Ant Design - How to restrict clickable area of table headers when sorting
- Material UI - Type 'string' is not assignable to type Icon
- State is null initially after using get request in componentDidMount
- Is there a way to add headings separating data in react-virtualized
- React Redux Form (Multiple Forms) - Routing & State Handling Issue
- How to detect long touch in javascript in mobile devices without jQuery
- React: default props error
- Slate: push to database and show in web
- Arrow function should not return assignment Eslint
- I get this error message when I try to test run my MySQL database
- React.js Authentication redirects to login on each refresh
- Error :: DELETE http://localhost:3000/users/todo/delete/undefined 404 (Not Found)