【问题标题】:Property 'create' does not exist on type类型上不存在属性“创建”
【发布时间】:2021-11-09 00:54:05
【问题描述】:

我正在尝试联系 API,但是当我使用 axios.create() 时,我收到一条错误消息:

Property 'create' does not exist on type 'typeof import("Stuff/Stuff/Stuff/My_app/Frontend/app/node_modules/axios/index")

代码:

import axios from "axios";

//Error here:
axios.create({
baseURL:"http://MyFantasticAPI.com(Not a real api)"
});

【问题讨论】:

  • Seems to work fine for me 你确定你已经在你的环境中安装了这个模块吗? (通过npmyarn 等)
  • 无论如何我都会尝试谢谢!

标签: reactjs typescript axios frontend


【解决方案1】:

试试

const instance = axios.default.create({
    baseURL: 'http://MyFantasticAPI'
  });

【讨论】:

    猜你喜欢
    • 2021-01-09
    • 2021-07-10
    • 2021-03-05
    • 2017-07-22
    • 2023-03-26
    • 2023-04-02
    • 2019-12-20
    • 2021-12-07
    相关资源
    最近更新 更多