我试图发送当前登录用户名从django后端,以反应前端。我已经创建了一个端点currentuser/,它在后端非常好地工作,它返回预期的结果,但是当我使用axios调用这个api端点时,那里会返回空值。
这是后端的代码
#view.py
from django.contrib.auth import get_user_model
from rest_framework import serializers
from rest_framework.response import Response
from rest_framework.views import APIView
User = g
我正在尝试从AWS Lambda内部调用AIRTABLE中的rest api端点,但没有成功。我没有得到错误,没有输出。
如果我使用node调用相同的代码,它就能工作。
我可以在我的代码中使用Axios。
纯airtable代码(works)
var Airtable = require('airtable');
var base = new Airtable({apiKey: 'keyoMYSECRETKEY'}).base('Mybaseid');
base('MyBase').select({maxRecords: 3,v
我在本地工作区环境中有一个data.json文件。该应用程序是客户端,只有。
我不确定使用这类数据的最佳(建议)方式是通过以下方式:
import data from './data.json'
// and got to town on it...
或者,如果我应该通过GET请求 (fetch、axios等)将这些数据带到我的React组件中,那么我就会将它放在componentDidMount中。
async componentDidMount() {
const data = 'http://localhost:3000/data.json'
我尝试从端点获取数据,但得到错误:对象作为您打算呈现一个子代集合的React child..If无效,请使用数组代替。 import React, { useState, useEffect } from "react";
import { useHistory } from "react-router-dom";
import axios from "axios";
import PropTypes from "prop-types";
import Movie from "./Movie/Movie";
我是新的反应和获取数据api。我不知道如何在我的组件中显示json数据。我使用axios从api获取数据,这是我返回的json数据。
{
"result": true,
"items": [
{
"excerpt": "egghead is your source for the Badass Portfolio Projects you need to climb the career ladder as a modern web developer.",
"_id": 3
我使用axios从api端点获取数据。我使用getAllUser()方法获取数据,displayUsers()从数据中显示userName和email。我无法在控制台中获得JSON响应。我还在chrome中看到了XHR,但是请求不是针对那个API端点提出的。请告诉我,我应该在getAllUser()和displayUsers()中更改什么,因为我认为我在这些方法中做错了什么。
代码:
import React, { Component } from 'react';
import axios, { post } from 'axios';
class App
我有一个使用reactjs和axios制作的index.html。它是从我的apache本地主机提供的。
我在我的铬浏览器中打开链接http://localhost/~user/index.html。我已经启用了CORS使用在铬插件。
当我尝试在twitter中使用axios时,我得到:
Response for preflight has invalid HTTP status code 400
下面是axios的代码:
var url = 'https://api.twitter.com/1.1/search/tweets.json';
我有带有CRUD的rest Web Api控制器。我需要添加一个自定义的POST端点: public class TherapistController : ApiController
{
public IHttpActionResult Post(TherapistModel therapistModel)
{
return Ok(therapist);
}
public IHttpActionResult SendConfirmationEmail(TherapistModel therapis