I am new to The Movie Database API. I created a Vue project and when I npm run serve
and go to my localhost
I see my app for 1 second and after that, I get a 403 with this error:
403 ERROR The request could not be satisfied. Request blocked. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner. If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation. Generated by cloudfront (CloudFront) Request ID: Pp4URUVnBrt7ovECZ1OEJPM9nW_N5ZE4sgxMuTAbG3A80reupMAAsw=="
When I debug I get this:
...\MovieAppVue\src\services\Network.js:1
import config from '../config/index'
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Module._compile (internal/modules/cjs/loader.js:895:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11
aiting for the debugger to disconnect...
When I test API key on their site I get 200 OK responses, so the API key is good. Can someone please check my repo to see what I am doing wrong? I don't know what I am missing here.
https://github.com/ivanradunkovic/MovieApp
import config from '../config/index'
import {storageService, storageKeys} from '../mixins/storageService'
class Network {
static methods = {
GET: 'GET',
POST: 'POST'
}
addApiKey(url) {
return `${url}?api_key=${config.API_KEY}`
}
addSessionId(url) {
const sessionId = storageService.methods.storageGet(storageKeys.SESSION_ID)
return sessionId ? `${url}&session_id=${sessionId}` : url
}
constructUrl(url, queryParams) {
url = this.addApiKey(`${config.API_BASE_URL}${url}`)
url = this.addSessionId(url)
for (let key in queryParams) url += `&${key}=${queryParams[key]}`
return url
}
async fetch(url, method, options = {}) {
const res = await fetch(this.constructUrl(url, options.params), {
method,
body: JSON.stringify(options.data),
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
}
})
return await res.json()
}
}
export default Network