这是我的代码,这是导致问题。我有Axios,我不知道如何有效地使用它。
import axios from "axios";
const options = {
headers: {
'content-type': 'application/json',
ContentType: 'text/json; charset=utf-8',
'X-RapidAPI-Key': 'REACT_APP_KEY',
'X-RapidAPI-Host': 'rdrunnerxx-trackservice.p.rapidapi.com'
},
data: '{"Locations":[{"LatLong":{"Latitude":39.767968, "Longitude": 64.421725}},{"LatLong":{"Latitude":40.022882 , "Longitude": 64.516878}}],"RouteOptions":{"DistanceUnit":0,"RouteOptimize":0,"Culture":"en-US","MapSize":null,"RouteColor":null}}'
};
export const ApiService = {
async fetching() {
const response = axios.post('https://rdrunnerxx-trackservice.p.rapidapi.com/route', data, { options })
return response
},
}
const response = axios.post('url', data, { options })
const data = ?
2条答案
按热度按时间huus2vyu1#
我认为你需要编辑ContentType为“Content-Type”:“application/json”
文档:https://axios-http.com/docs/post_example
vyswwuz22#
这个应该能用
使用“提取”功能