'Can't make Twitter search with React and Twit

I am trying to use Twit library on codesandbox.io . I added dependency Twit and followed documentation. Console returns nothing. In the code below I replaced actual keys with ###

import React from "react";
import ReactDOM from "react-dom";
import Twit from "twit";

import "./styles.css";

/* I included ### instead of secrets */
const user = new Twit({
  consumer_key: "###",
  consumer_secret: "###",
  access_token: "###",
  access_token_secret: "###"
});

user.get("search/tweets", { q: "banana", count: 100 }, function(
 err,data,response) {
    console.log(data);
 });


Solution 1:[1]

If I replace

import Twit from "twit";

with

var Twit = require('twit');

I get your code to working. I'm sorry I can't explain why.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Noah