Closed johnvirp closed 2 years ago
Describe the bug ReferenceError: SpotifyWebApi is not defined
To Reproduce Steps to reproduce the behavior:
- Run code
Expected behavior I just want it to be accessed
A familiar problem. Haven't found a solution yet?
@johnvirp Thanks for reporting it! It would be extremely useful if you could provide a code snippet and information about what environment you are running it on. Otherwise it’s impossible to troubleshoot.
@johnvirp, Sorry if I'm interrupting the conversation, but I have exactly the same problem. I'm creating a bot that will search for songs on Spotify and send the result a link to the song. I create this on Dialogflow, in the Fulfillment Inline Editor. Here is my code:
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
async function search(agent) {
const spotify = require("spotify-api.js");
const Auth = new spotify.Auth();
var token = await Auth.get({
client_id: "<client_id>",
client_secret: "<client_secret>",
}); // Will return a promise of token
var Spotify = require('spotify-web-api-js');
var s = new Spotify();
var spotifyApi = new SpotifyWebApi(); //Here Error
spotifyApi.setAccessToken(token);
}
let intentMap = new Map();
intentMap.set('Spotify', search);
agent.handleRequest(intentMap);
});
I did not continue to write the code where the search will be performed, because this line does not work
Hi, sorry for interrupting. i'm facing the same problem too. i'm currently working on WebApp that will get few user tracks on spotify and find a snippet of lyrics of that song. i installed it via node , and also using browserify to merge the nodes into a single .js file.
Sorry I ended up using this wrapper instead https://github.com/thelinmichael/spotify-web-api-node. I am using this for a project that is due very soon for a class so I didn't have the time to troubleshoot it.
Describe the bug ReferenceError: SpotifyWebApi is not defined
To Reproduce Steps to reproduce the behavior:
Expected behavior I just want it to be accessed